or<F> method

  1. @override
Result<T, F> or<F>(
  1. Result<T, F> res
)
override

Returns res if the result is Err, otherwise returns the Ok (success) value of this.

Examples

Basic usage:

Result<int, String> x = Ok(2);
Result<int, String> y = Err('late error');
expect(x.or(y), Ok<int, String>(2));

Result<int, String> x = Err('early error');
Result<int, String> y = Ok(2);
expect(x.or(y), Ok<int, String>(2));

Result<int, String> x = Err('not a 2');
Result<int, String> y = Errint, String>('late error');
expect(x.or(y), Errint, String>('late error'));

Result<int, String> x = Ok(2);
Result<int, String> y = Ok(100);
expect(x.or(y), Ok<int, String>(2));

Implementation

@override
Result<T, F> or<F>(Result<T, F> res) {
  return Ok(v);
}