and<R> method

Option<R> and<R>(
  1. Option<R> other
)

Returns other when this option is present, and None otherwise.

final next = const Some<int>(1).and(const Some<String>('a')); // Some(a)

Implementation

Option<R> and<R>(Option<R> other) {
  return switch (this) {
    Some<T>() => other,
    None<T>() => None<R>(),
  };
}