fun main() {
aif({ 4 }, {
println("it is $it")
}, {});
}
fun
<T
> aif
(exp: () -> T
?, thenBody
: (T
) -> Unit
, elseBody
: () -> Unit
) { if (it != null)
thenBody(it)
else
elseBody()
}
CmZ1biBtYWluKCkgewogICAgYWlmKHsgNCB9LCB7CiAgICAJcHJpbnRsbigiaXQgaXMgJGl0IikKICAgIH0sIHt9KTsKfQoKZnVuIDxUPiBhaWYoZXhwOiAoKSAtPiBUPywgdGhlbkJvZHk6IChUKSAtPiBVbml0LCBlbHNlQm9keTogKCkgLT4gVW5pdCkgewoJdmFsIGl0ID0gZXhwKCkKCWlmIChpdCAhPSBudWxsKQoJCXRoZW5Cb2R5KGl0KQoJZWxzZQoJCWVsc2VCb2R5KCkKfQ==