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