Skip to content

Tuple4EitherOps<E, T1, T2, T3, T4>

extension Tuple4EitherOps<E, T1, T2, T3, T4> on Record

Provides additional functions on tuple with 4 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 Tuple4EitherOps<E, T1, T2, T3, T4> extension

Implementation
dart
Either<E, (T1, T2, T3, T4)> get tupled => init.tupled.flatMap((x) => last.map(x.appended));

Methods

mapN() extension

Either<E, T5> mapN<T5>(T5 Function(T1, T2, T3, T4) 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 Tuple4EitherOps<E, T1, T2, T3, T4> extension

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