redeem<C> method
- @useResult
- required C leftOperation(
- L value
- required C rightOperation(
- R value
Redeem an Either to an Either by resolving the error or mapping the value R to C.
redeem is derived from map and handleError.
This is functionally equivalent to map(rightOperation).handleError(leftOperation).
Implementation
@useResult
Either<L, C> redeem<C>({
required C Function(L value) leftOperation,
required C Function(R value) rightOperation,
}) =>
_foldInternal(
ifLeft: (v) => leftOperation(v).right(),
ifRight: (v) => rightOperation(v).right(),
);