map<U> method

Expected<U, E> map<U>(
  1. U mapper(
    1. T value
    )
)

Transforms the expected value of type T into a new value of type U using the provided mapper function.

If this object contains an error, the error is passed along unmodified.

Implementation

Expected<U, E> map<U>(U Function(T value) mapper) {
  if (_hasValue) {
    return Expected<U, E>.value(mapper(_value as T));
  } else {
    return Expected<U, E>.error(_error as E);
  }
}