unwrapOrElse abstract method

  1. @useResult
T unwrapOrElse(
  1. T calculateDefaultValue()
)

Returns the contained value, if any, or the result of calculateDefaultValue otherwise.

Examples

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

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

Implementation

@useResult
T unwrapOrElse(T Function() calculateDefaultValue);