zipWith<U, R> method
Combines this value with other's, when both are present.
combine is not called unless both are present.
final sum = const Some<int>(1).zipWith(const Some<int>(2), (a, b) => a + b);
Implementation
Option<R> zipWith<U, R>(
Option<U> other, R Function(T left, U right) combine) {
return switch ((this, other)) {
(Some<T>(value: final left), Some<U>(value: final right)) =>
Some<R>(combine(left, right)),
_ => None<R>(),
};
}