map<U extends Object> method

Result<U, E> map<U extends Object>(
  1. U onOk(
    1. T
    )
)

Maps the value from T to U if it is Ok, else, keeps the Err, E.

Implementation

Result<U, E> map<U extends Object>(U Function(T) onOk) {
  return switch (this) {
    Ok(:final T value) => Ok(onOk(value)),
    Err(:final E err) => Err(err),
  };
}