Created
September 16, 2022 05:42
-
-
Save s1monw1/167ec9431a539a7a2a56ef1b19d1a1b4 to your computer and use it in GitHub Desktop.
This file contains 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
object Foo { | |
fun ClosedRange<Int>.random() = | |
Random().nextInt(endInclusive - start) + start | |
} | |
// random() can only be used in context of Foo | |
with(Foo) { | |
val rnd = (0..10).random() | |
println(rnd) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment