mapOr<U> abstract method
- @useResult
- U map(
- T value
- U defaultValue
Returns the contained value, if any, with map
applied to it, or defaultValue
otherwise.
Examples
// prints "4"
print(const Ok<int, String>(2).mapOr((value) => value * 2, 0));
// prints "0"
print(const Err<int, String>('error').mapOr((value) => value * 2, 0));
Implementation
@useResult
U mapOr<U>(U Function(T value) map, U defaultValue);