zipOp<T, U, W> function

Option<W> zipOp<T, U, W>(
  1. Option<T> a,
  2. W op(
    1. T a,
    2. U b
    ),
  3. Option<U> b
)

Works like Option.zipWith, but it is a bit more operation friendly.

Zips this Option with another Option using the provided function, returning a Record of their held values. If any of the two options is a None, it returns a None<(T, U)>.

Examples

int plus(int a, int b) => a + b;
final Option<int> a = Some(8);
final Option<int> b = Some(19);
zipOp(a, plus, b); // Some(27)

Implementation

Option<W> zipOp<T, U, W>(
  Option<T> a,
  W Function(T a, U b) op,
  Option<U> b,
) =>
    a.zipWith(b, op);