tapLeft method

Either<L, R> tapLeft(
  1. void f(
    1. L value
    )
)

The given function is applied as a fire and forget effect if this is a Left. When applied the result is ignored and the original Either value is returned.

Example

Right<int, int>(12).tapLeft((_) => println('flower')); // Result: Right(12)
Left<int, int>(12).tapLeft((_) => println('flower'));  // Result: prints 'flower' and returns: Left(12)

Implementation

Either<L, R> tapLeft(void Function(L value) f) {
  if (isLeft) {
    f(_unionValue as L);
  }
  return this;
}