Add Unless Keyword

You can easily recreate the unless behavior in Kotlin like this:
fun unless(condition: Boolean, block: () → Unit){
if (!condition) block()
}

And it can be used like this
unless(false) { println("unless in Kotlin") }

I am not sure though if it is possible to create the else block

1 Like