ifNull

inline fun <T> T?.ifNull(block: (T?) -> Any): Any

ifNull execute when value is null.

Example:

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

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

Since

1.1.0

Return

value or Unit