map

inline fun <In : Any, Out : Any, ErrorIn : Any, ErrorOut : Any> Outcome<In, ErrorIn>.map(success: (In) -> Out, failure: (ErrorIn) -> ErrorOut): Outcome<Out, ErrorOut>

Transform an Outcome with either success or failure.

  • Unlike, fold, map re-wraps each transform as the same kind of Outcome.

  • This function does not provide a RaiseScope, and makes no guarantees about catching, handling, or rethrowing errors! Use andThen/tryRecover or outcomeOf within the transformation lambdas for that.

Receiver

The Outcome<In, ErrorIn> to transform.

Return

A new Outcome<Out, ErrorOut> with the transformed value.

Parameters

In

The Ok type of the receiver Outcome.

Out

The Ok type of the returned Outcome.

ErrorIn

The Error type of the receiver Outcome.

ErrorOut

The Error type of the returned Outcome.

success

The transform to apply if the receiver Outcome is an Outcome.Success.

failure

The transform to apply if the receiver Outcome is an Outcome.Failure.

See also