ifEmpty

inline fun <C : Array<*>, R, R> C.ifEmpty(defaultValue: () -> R): R(source)

Returns this array if it's not empty or the result of calling defaultValue function if the array is empty.

Since Kotlin

1.3

Samples


inline fun <C : Collection<*>, R, R> C.ifEmpty(defaultValue: () -> R): R(source)

Returns this collection if it's not empty or the result of calling defaultValue function if the collection is empty.

Since Kotlin

1.3

Samples


inline fun <M : Map<*, *>, R, R> M.ifEmpty(defaultValue: () -> R): R(source)

Returns this map if it's not empty or the result of calling defaultValue function if the map is empty.

Since Kotlin

1.3

Samples