getOrDefault

fun <R, T : R & Any> Optional<T>.getOrDefault(defaultValue: R): R(source)

Returns this Optional's value if present, or otherwise defaultValue.

Since Kotlin

1.7