Nicolas Chaduc
05/25/2018, 8:18 AMfun ifLet(value: Any?, code: ((Any) -> Unit)): Boolean {
value?.let {
code.invoke(it)
return true
}
return false
}
fun Boolean.elseLet(code: () -> Unit) {
if (!this) {
code.invoke()
}
}
for use :
ifLet(myMutableValue, {
System.out.println("Call of ifLet Code myInt value = $it")
}).elseLet {
System.out.println("Call of elseLet Code")
}
?diesieben07
05/25/2018, 8:22 AMval
and a normal if.