orElse<F> abstract method

Result<T, F> orElse<F>(
  1. Result<T, F> next(
    1. E error
    )
)

Chains another result-producing operation when this result failed.

Use this for fallback reads or error recovery that can still fail.

Result<int, String> readPrimary() => const Err('cache miss');
Result<int, String> readFallback(String error) => const Ok(42);

final value = readPrimary().orElse(readFallback);

Implementation

Result<T, F> orElse<F>(Result<T, F> Function(E error) next);