spnda
'if' must have both main and 'else' branches if used as an expression
fun exampleFunc(someBoolean: Boolean) = when (someBoolean) { else -> { val otherBoolean = Random.nextBoolean() if (otherBoolean) { print("Yay!") } } }
kqr
Adam Powell
if (otherBoolean) { val t = 1 }
Rob Elliot
else
val t = if (otherBoolean} { 1 }
t
otherBoolean
false
when
Stephan Schroeder
= when(...) {
fun exampleFunc(someBoolean: Boolean) { when (someBoolean) { else -> { val otherBoolean = Random.nextBoolean() if (otherBoolean) { print("Yay!") } } } }
A modern programming language that makes developers happier.