Created
June 28, 2019 14:41
-
-
Save stewsters/cf543e21a543f05fb3470aad1e464fad to your computer and use it in GitHub Desktop.
Kotlin allow you to destructure ranges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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