flatMapOrElse<U, F> method

Result<U, F> flatMapOrElse<U, F>(
  1. Result<U, F> f(
    1. T
    ),
  2. Result<U, F> e(
    1. E
    )
)

Maps Result<T, E> to Result<U, E>, leaving an Err value untouched.

Allows chaining Results without nesting them.

Implementation

Result<U, F> flatMapOrElse<U, F>(
  Result<U, F> Function(T) f,
  Result<U, F> Function(E) e,
) =>
    isOk ? f(_value) : e(_error);