orElse abstract method

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

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

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