map

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

Transforms both states of an Outcome, re-wrapping each result in the same kind of Outcome.

  • Unlike fold, the result is always an Outcome — each lambda returns the unwrapped value/error, not the wrapper.

  • Unlike flatMapSuccess / flatMapFailure, the lambdas here return plain values; the Outcome wrapper is added automatically.

  • No error handling is provided.

Parameters

success

Applied when the receiver is a Success; returns the new value.

failure

Applied when the receiver is a Failure; returns the new error.

See also