Skip to content

Tuple2EitherOps<E, T1, T2>

extension Tuple2EitherOps<E, T1, T2> on Record

Provides additional functions on tuple with 2 Eithers.

Properties

tupled extension no setter

Either<E, Record> get tupled

If all items of this tuple are a Right, the respective items are turned into a tuple and returned as a Right. If any item is a Left, the first Left encountered is returned.

Available on Record, provided by the Tuple2EitherOps<E, T1, T2> extension

Implementation
dart
Either<E, (T1, T2)> get tupled => $1.flatMap((a) => $2.map((b) => (a, b)));

Methods

mapN() extension

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

Applies fn to the values of each respective tuple member if all values are a Right. If any item is a Left, the first Left encountered will be returned.

Available on Record, provided by the Tuple2EitherOps<E, T1, T2> extension

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