marcinmoskala
11/21/2017, 2:34 PMfun bigger(a: Int, b: Int) = if (a > b)
a
else
b
fun greet(a: Any) = when (a) {
is String -> "Hello String"
is Number -> "Hello Number"
else -> "I don't know you! Go away!"
}
yole
11/27/2017, 4:50 PMwhen
example looks really nice for a one-argument function with a short name, but the when
becomes much harder to see when the formatting puts it into column 90marcinmoskala
11/29/2017, 5:39 AMfun someLongAndStrangeFunction() = when {
predicateOne && predicateTwo || predicateThree && predicteFour ->
"AAAAAA"
else ->
"BBBBBB"
}
marcinmoskala
11/29/2017, 5:41 AM