flatMapOrNull<R> method

Either<K, R>? flatMapOrNull<R>(
  1. Either<K, R> f(
    1. V
    )
)

Applies a function returning an Either to the value if the Either is Right; otherwise, returns null.

Example usage:

Either<String, int> either = Right(42);
Either<String, String> result = either.flatMapOrNull((value)
  => Right(value.toString()));
// returns: Right('42')

Implementation

Either<K, R>? flatMapOrNull<R>(Either<K, R> Function(V) f) =>
    fold((_) => null, (v) => f(v));