fun test() = 42 fun foo() { when (val a = test()) { 1 -> a else -> 24 } }