map<U> method

Result<U, E> map<U>(
  1. U f(
    1. T value
    )
)

Maps the value if successful, otherwise returns the error as is.

Implementation

Result<U, E> map<U>(U Function(T value) f) {
  if (this is Success<T, E>) {
    return Result.ok(f((this as Success<T, E>).value));
  }
  return Result.error((this as Failure<T, E>).error);
}