orElse method

  1. @override
  2. @useResult
Option<T> orElse(
  1. Option<T> calculateOther()
)
override

Returns a Some of the original value if this is a Some, or the result of calculateOther otherwise.

Examples

// prints "Some(2)"
print(const Some(2).orElse(() => const Some(3)));

// prints "Some(3)"
print(const None<int>().orElse(() => const Some(3)));

Implementation

@override
@useResult
Option<T> orElse(Option<T> Function() calculateOther) => calculateOther();