nkiesel
01/22/2019, 8:36 AMval b = when(val computed = f()) { computed > 0 -> computed + 1 ; else -> computed - 1 } but this produces a syntax error. Is the only way really to use val computed = f(); val b = when { computed > 0 -> computed + 1 ; else -> computed - 1 } (with leaking of computed outside of the when scope)?Alowaniak
01/22/2019, 8:41 AMval b = f().let { when { it > 0 -> it + 1; else -> it - 1} }
I guess if computed is an int then
val b = when(val computed = f()) {
in 1..Int.MAX_VALUE -> computed + 1
else -> computed - 1
} could also worknkiesel
01/22/2019, 8:56 PMlet solution, thanks!