rfold

inline fun <Ok : Any, Error : Any, Output> Outcome<Ok, Error>.rfold(failure: (Error) -> Output, success: (Ok) -> Output): Output

Reverse fold is syntax-sugar that swaps the lambda argument order.

val outcome: Outcome<String, Throwable> = ...

throw outcome.rfold(failure = ::itself) { // it: Ok ->
IllegalStateException("Expected an error, got: $it")
}

See also

collapse