mapOrElse<U> abstract method
- @useResult
- U map(
- T value
- U calculateDefaultValue()
Returns the contained value, if any, with map
applied to it, or the result of
calculateDefaultValue
otherwise.
Examples
// prints "some: 2"
print(const Some(2).mapOrElse((value) => 'some: $value', () => 'none'));
// prints "none"
print(const None<int>().mapOrElse((value) => 'some: $value', () => 'none'));
Implementation
@useResult
U mapOrElse<U>(U Function(T value) map, U Function() calculateDefaultValue);