The signature of takeIf (and takeUnless) is:
public inline fun <T> T.takeIf(predicate: (T) -> Boolean): T?
instead of:
public inline fun <T : Any> T?.takeIf(predicate: (T) -> Boolean): T?
Why does Kotlin allow null as a possible value passed to the predicate? What is the rationale for not restricting T to non-null types?