takeIf

Common
JVM
JS
Native
1.1
inline fun <T> T.takeIf(predicate: (T) -> Boolean): T?

Returns this value if it satisfies the given predicate or null, if it doesn't.