fun main() { si(true){ println("True") } sino { println("False") } val result = si(true){ println("True") } sino { println("False") } println(result) } private fun si(booleano: Boolean, function: () -> Unit):Boolean{ if(booleano){ function()} return booleano } private infix fun Boolean.sino(function: () -> Unit):String { if(!this){ function() } return this.toString().capitalize() }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter