fold

inline suspend fun <T, R> Outcome<T>.fold(onSuccess: suspend (T) -> R, onFailure: suspend (String, Throwable?) -> R): R

Folds the Outcome into a single value by applying onSuccess for a Success or onFailure for a Failure.

Return

The result of applying the appropriate function.

Parameters

onSuccess

The function to apply to the value of a Success.

onFailure

The function to apply to the message and throwable of a Failure.