map<U> method

Result<U> map<U>(
  1. U transform(
    1. V
    )
)

The given function is applied if this is a Value.

Example:

Result.value(12).map ( (v) => "flower" ) // Result: ValueResult("flower")
Result.error(12).map ( (v) =>  "flower" ) // Result: ErrorResult(12)

Implementation

$async.Result<U> map<U>(U Function(V) transform) {
  if (isValue) {
    return $async.Result.value(transform(asValue!.value));
  } else {
    return $async.Result.error(asError!.error);
  }
}