fold
inline fun <T, R, E> Iterable<T>.fold(initial: R, operation: (R, T) -> Result<R, E>): Result<R, E>
Content copied to clipboard
Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.
inline fun <V, E, U> Result<V, E>.fold(success: (V) -> U, failure: (E) -> U): U
Content copied to clipboard
Maps this Result to U by applying either the success function if this Result is Ok, or the failure function if this Result is an Err. Both of these functions must return the same type (U).
This is functionally equivalent to mapBoth.
Elm: Result.Extra.mapBoth
Haskell: Data.Either.either