getOrElse

Common
JVM
JS
Native
1.3
inline fun <R, T : R> Result<T>.getOrElse(
    onFailure: (exception: Throwable) -> R
): R

(source)

Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated Throwable exception if it is failure.

Note, that this function rethrows any Throwable exception thrown by onFailure function.

This function is a shorthand for fold(onSuccess = { it }, onFailure = onFailure) (see fold).