redeem<C> method

Either<L, C> redeem<C>({
  1. required C leftOperation(
    1. L value
    ),
  2. required C rightOperation(
    1. 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

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(),
    );