kotlin reto si sino

PHOTO EMBED

Thu Jun 30 2022 10:31:08 GMT+0000 (UTC)

Saved by @ericggDev #kotlin

   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()
    }
content_copyCOPY