orElse method

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

Returns the option if it contains a value, otherwise calls f and returns the result.

Implementation

Option<T> orElse(Option<T> Function() f) {
  return switch (this) { Some() => this, _ => f() };
}