zip<U> method

Option<(T, U)> zip<U>(
  1. Option<U> other
)

Pairs this value with other's, when both are present.

final point = const Some<int>(1).zip(const Some<int>(2)); // Some((1, 2))

Implementation

Option<(T, U)> zip<U>(Option<U> other) {
  return switch ((this, other)) {
    (Some<T>(value: final left), Some<U>(value: final right)) =>
      Some<(T, U)>((left, right)),
    _ => None<(T, U)>(),
  };
}