Afzal Najam
10/31/2020, 3:09 AMalways
in a when block? Like
when (something) {
FIRST_CASE -> doThis()
SECOND_CASE -> doThat()
else -> doSomethingElse()
always -> andAlwaysDoThis()
}
I mean, sure, we can just write the always part outside of the when block but not when it's an expression body.
Just wondering.Adam Powell
10/31/2020, 3:29 AMAfzal Najam
10/31/2020, 5:14 AMCLOVIS
10/31/2020, 4:20 PMwhen (something) {
FIRST_CASE -> doThis()
SECOND_CASE -> doThat()
else -> doSomethingElse()
}.also { andAlwaysDoThis() }
Which is almost the same length and probably as readable, and it can still be used in single-line functionsAfzal Najam
10/31/2020, 4:23 PM