OptionCombine<T> extension
Combining Option values, and moving between Option and Result.
final both = const Some<int>(1).zip(const Some<String>('a')); // Some((1, a))
final checked = const None<int>().okOr('missing'); // Err(missing)
- on
-
- Option<
T>
- Option<
Methods
-
okOr<
E> (E error) → Result< T, E> -
Available on Option<
Returns Ok with a present value, or Err withT> , provided by the OptionCombine extensionerrorwhen absent. -
okOrElse<
E> (E error()) → Result< T, E> -
Available on Option<
Returns Ok with a present value, or computes an Err when absent.T> , provided by the OptionCombine extension -
zip<
U> (Option< U> other) → Option<(T, U)> -
Available on Option<
Pairs this value withT> , provided by the OptionCombine extensionother's, when both are present. -
zipWith<
U, R> (Option< U> other, R combine(T left, U right)) → Option<R> -
Available on Option<
Combines this value withT> , provided by the OptionCombine extensionother's, when both are present.