orElse method

Result<T, E> orElse(
  1. Result<T, E> alternative()
)

If this Result is Err, provides a default value (or another Result).

Implementation

Result<T, E> orElse(Result<T, E> Function() alternative) {
  if (this is Ok<T, E>) {
    return this;
  }
  return alternative();
}