Using operators with lambdas
suggest changeIf you have:
val r = Random(233)
infix inline operator fun Int.rem(block: () -> Unit) {
if (r.nextInt(100) < this) block()
}
You can write the following DSL-like code:
20 % { println("The possibility you see this message is 20%") }
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents