fun test(b: Boolean) { var fn: () -> String when (b) { true -> fn = { "foo" } else -> fn = { "bar" } } }