map<A, B> abstract method

Result<A, B> map<A, B>({
  1. A ok(
    1. O ok
    )?,
  2. B err(
    1. E err
    )?,
})

Take the current Result and transform it's values to a new Result.

Example:

  final result = ok<String, Exception>('hi');

  Result<int, Error> newResult = result.map(
    ok: (ok) => 1,
    err: (err) => Error(),
  );

Implementation

Result<A, B> map<A, B>({A Function(O ok)? ok, B Function(E err)? err});