Skip to content

Instantly share code, notes, and snippets.

@stewsters
Created June 28, 2019 14:41
Show Gist options
  • Save stewsters/cf543e21a543f05fb3470aad1e464fad to your computer and use it in GitHub Desktop.
Save stewsters/cf543e21a543f05fb3470aad1e464fad to your computer and use it in GitHub Desktop.
Kotlin allow you to destructure ranges
// Lets you destructure ranges.
val (start, end) = (0..10)
private operator fun <T:Comparable<T>> ClosedRange<T>.component1(): T = this.start
private operator fun <T:Comparable<T>> ClosedRange<T>.component2(): T = this.endInclusive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment