Lukasz Kalnik
07/22/2022, 11:53 AMif ... else
expression?
val myLambda: () -> Unit = if (condition) doSomethingLambda else {{}}
Jurriaan Mous
07/22/2022, 11:54 AMelse { Unit }
Lukasz Kalnik
07/22/2022, 11:55 AMif (condition) {
doSomething
} else {
{}
}
Jurriaan Mous
07/22/2022, 12:00 PMLukasz Kalnik
07/22/2022, 12:01 PMJurriaan Mous
07/22/2022, 12:02 PMfun emptyFunction() {}
And use
else ::emptyFunction
That is the only alternative I can think of nowLukasz Kalnik
07/22/2022, 12:02 PMval myLambda: () -> Unit = if (cond) lambda else fun() {}
Jurriaan Mous
07/22/2022, 12:09 PMelse fun() = Unit
but still not elegant indeed.Sam
07/22/2022, 12:45 PMif (condition) doSomethingLambda else ({})
Jurriaan Mous
07/22/2022, 12:49 PM