getOrElse

inline fun <R, T : R> Result<T>.getOrElse(onFailure: (exception: PubNubException) -> R): R

Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated PubNubException 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).