Skip to content

Tuple2OptionOps<T1, T2>

extension Tuple2OptionOps<T1, T2> on Record

Provides additional functions on a tuple of 2 Options.

Properties

tupled extension no setter

Option<Record> get tupled

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

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

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

Methods

mapN() extension

Option<T3> mapN<T3>(T3 Function(T1, T2) fn)

Applies fn to the values of each respective tuple member if all values are a Some. If any item is a None, None will be returned.

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

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