mapLeft<C> method

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

The given function is applied if this is a Left.

Example

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

Implementation

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