All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.hnau.jutils.ExtensionsForNullable.kt Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package ru.hnau.jutils




inline fun  T?.handle(ifNotNull: (T) -> R, ifNull: () -> R) =
        if (this == null) ifNull.invoke() else ifNotNull.invoke(this)

fun  T?.handle(forNotNull: R, forNull: R) =
        if (this == null) forNull else forNotNull

inline fun  T?.ifNotNull(action: (T) -> R) = this?.let(action)

inline fun  T?.ifNull(action: () -> R) = if (this == null) action.invoke() else null

fun  ((Unit) -> T).invoke() = invoke(Unit)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy