match<R> method

R match<R>({
  1. required R ok(
    1. T value
    ),
  2. required R err(
    1. E error
    ),
})

Pattern matches on the result, invoking ok or err accordingly.

Implementation

R match<R>({
  required R Function(T value) ok,
  required R Function(E error) err,
}) {
  final self = this;
  if (self is Ok<T, E>) return ok(self.value);
  return err((self as Err<T, E>).error);
}