fold

inline fun <R> fold(onSuccess: (T) -> R, onError: (E) -> R): R

Invokes exactly one branch and returns its value. Callback exceptions propagate.

Parameters

onSuccess

Handler for the success value.

onError

Handler for the typed error.