andThen<U> method

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

Applies a function to the value inside Ok if it exists, otherwise returns Err.

Implementation

Result<U, E> andThen<U>(Result<U, E> Function(T value) fn) {
  if (this is Ok<T, E>) {
    return fn((this as Ok<T, E>).value);
  }
  return this as Result<U, E>;
}