toNonNull

inline fun <T> T?.toNonNull(default: T): T

Get a non-null value itself for the nullable value. If the value itself is null, it returns the specified default value. a default value if the nullable value is null

Return

A non-null value itself, or default if the value itself is null.

Parameters

default

A default value


Get a non-null boolean value itself for the nullable boolean value.

Return

A non-null boolean value itself, or false if the value itself is null.


fun Int?.toNonNull(): Int

Get a non-null integer value itself for the nullable integer value.

Return

A non-null integer value itself, or zero if the value itself is null.


Get a non-null long value itself for the nullable long value.

Return

A non-null long value itself, or zero if the value itself is null.


Get a non-null float value itself for the nullable float value.

Return

A non-null float value itself, or zero if the value itself is null.


Get a non-null double value itself for the nullable double value.

Return

A non-null double value itself, or zero if the value itself is null.


Get a non-null string value itself for the nullable string value.

Return

A non-null string value itself, or an empty string if the value itself is null.


inline fun <T> Array<T>?.toNonNull(): Array<T>

Get a non-null array itself for the nullable array.

Return

A non-null array itself, or an empty array if the array itself is null.


inline fun <E> List<E>?.toNonNull(): List<E>

Get a non-null list itself for the nullable list.

Return

A non-null list itself, or an empty list if the list itself is null.


inline fun <E> Set<E>?.toNonNull(): Set<E>

Get a non-null set itself for the nullable set.

Return

A non-null set itself, or an empty set if the set itself is null.


inline fun <K, V> Map<K, V>?.toNonNull(): Map<K, V>

Get a non-null map itself for the nullable map.

Return

A non-null map itself, or an empty map if the map itself is null.