rfold
inline fun <Ok, Error, Output> Outcome<Ok, Error>.rfold(success: Success<Ok>.() -> Output, failure: Failure<Error>.() -> Output): Output
Reverse fold — identical behaviour with swapped lambda argument order.
Useful when the trailing-lambda position reads more naturally as the success branch, or when naming failure explicitly would be awkward.
val outcome: Outcome<String, Throwable> = ...
throw outcome.rfold(failure = ::itself) { // it: Ok ->
IllegalStateException("Expected a failure, got: $it")
}Content copied to clipboard