andThen<U> method

Result<U, E> andThen<U>(
  1. Result<U, E> next(
    1. T value
    )
)

Chains another computation only when this result is successful.

Implementation

Result<U, E> andThen<U>(Result<U, E> Function(T value) next) {
  final self = this;
  if (self is Ok<T, E>) return next(self.value);
  return Err<U, E>((self as Err<T, E>).error);
}