getOrElse

inline fun <R, T : R & Any> Optional<T>.getOrElse(defaultValue: () -> R): R(source)

Returns this Optional's value if present, or otherwise the result of the defaultValue function.

Since Kotlin

1.7