map<R2> method

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

Maps the right value if this is a Right, otherwise returns this Left unchanged

Implementation

Either<L, R2> map<R2>(R2 Function(R) f) {
  return switch (this) {
    Left() => this as Either<L, R2>,
    Right(:final value) => Right(f(value)),
  };
}