unwrapOrElse method
T
unwrapOrElse(
- T fallback()
Returns the present value, or computes one when this option is absent.
fallback is not called when the option is present.
final count = const None<int>().unwrapOrElse(() => 0);
final existing = const Some<int>(7).unwrapOrElse(() => 0);
Implementation
T unwrapOrElse(T Function() fallback) {
return switch (this) {
Some<T>(:final value) => value,
None<T>() => fallback(),
};
}