alt method

Option<T> alt(
  1. Option<T> orElse()
)

Return the current Option if it is a Some, otherwise return the result of orElse.

Used to provide an alternative Option in case the current one is None.

[🍌].alt(() => [🍎]) -> [🍌]
[_].alt(() => [🍎]) -> [🍎]

Implementation

Option<T> alt(Option<T> Function() orElse) =>
    this is Some<T> ? this : orElse();