mapOr<U> abstract method

  1. @useResult
U mapOr<U>(
  1. U map(
    1. T value
    ),
  2. U defaultValue
)

Returns the contained value, if any, with map applied to it, or defaultValue otherwise.

Examples

// prints "some: 2"
print(const Some(2).mapOr((value) => 'some: $value', 'none'));

// prints "none"
print(const None<int>().mapOr((value) => 'some: $value', 'none'));

Implementation

@useResult
U mapOr<U>(U Function(T value) map, U defaultValue);