Skip to content

Instantly share code, notes, and snippets.

@s1monw1
Created September 16, 2022 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s1monw1/167ec9431a539a7a2a56ef1b19d1a1b4 to your computer and use it in GitHub Desktop.
Save s1monw1/167ec9431a539a7a2a56ef1b19d1a1b4 to your computer and use it in GitHub Desktop.
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