Skip to content

EitherTuple2Ops<E, T1, T2>

extension EitherTuple2Ops<E, T1, T2> on Either<E, Record>

Provides additional functions on an Either where the right value is a 2 element tuple.

Methods

ensureN() extension

Either<E, Record> ensureN(bool Function(T1, T2) p, E Function() onFailure)

Available on Either<A, B>, provided by the EitherTuple2Ops<E, T1, T2> extension

Implementation
dart
Either<E, (T1, T2)> ensureN(
  Function2<T1, T2, bool> p,
  Function0<E> onFailure,
) => ensure(p.tupled, onFailure);

filterOrElseN() extension

Either<E, Record> filterOrElseN(bool Function(T1, T2) p, E Function() zero)

Available on Either<A, B>, provided by the EitherTuple2Ops<E, T1, T2> extension

Implementation
dart
Either<E, (T1, T2)> filterOrElseN(
  Function2<T1, T2, bool> p,
  Function0<E> zero,
) => filterOrElse(p.tupled, zero);

flatMapN() extension

Either<E, T3> flatMapN<T3>(Either<E, T3> Function(T1, T2) f)

Available on Either<A, B>, provided by the EitherTuple2Ops<E, T1, T2> extension

Implementation
dart
Either<E, T3> flatMapN<T3>(Function2<T1, T2, Either<E, T3>> f) => flatMap(f.tupled);

foldN() extension

T3 foldN<T3>(T3 Function(E) f, T3 Function(T1, T2) g)

Available on Either<A, B>, provided by the EitherTuple2Ops<E, T1, T2> extension

Implementation
dart
T3 foldN<T3>(
  Function1<E, T3> f,
  Function2<T1, T2, T3> g,
) => fold(f, g.tupled);

foreachN() extension

void foreachN(void Function(T1, T2) f)

Available on Either<A, B>, provided by the EitherTuple2Ops<E, T1, T2> extension

Implementation
dart
void foreachN(Function2<T1, T2, void> f) => foreach(f.tupled);

mapN() extension

Either<E, T3> mapN<T3>(T3 Function(T1, T2) f)

Available on Either<A, B>, provided by the EitherTuple2Ops<E, T1, T2> extension

Implementation
dart
Either<E, T3> mapN<T3>(Function2<T1, T2, T3> f) => map(f.tupled);