
ru.hnau.jutils.ExtensionsForNullable.kt Maven / Gradle / Ivy
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