map<C> method

Either<L, C> map<C>(
  1. C f(
    1. R value
    )
)

The given function is applied if this is a Right.

Example

Right<int, int>(12).map((_) => 'flower'); // Result: Right('flower')
Left<int, int>(12).map((_) => 'flower');  // Result: Left(12)

Implementation

Either<L, C> map<C>(C Function(R value) f) => _foldInternal(
      ifLeft: (l) => Either<L, C>.left(l),
      ifRight: (r) => Either<L, C>.right(f(r)),
    );