ifNotNull

inline fun <T, R> T?.ifNotNull(block: (T) -> R): R?

ifNotNull execute when value isn't null.

Example:

val value: String? = null
value.ifNotNull { ... } // null
value.ifNotNull {
...
"i am not null"
} // null

val value2 = "hello"
value2.ifNotNull { ... } // Unit
value2.ifNotNull {
...
"i am not null"
} // i am not null

Since

1.1.0

Return

value or Unit