ResOr Method

Overload List

Or(FuncRes) (lazy version) Combines two results: this and other as follows:
  • returns this if this is Ok;
  • returns other otherwise.
C#
var or = Ok().Or(Ok());
Assert.True(or.IsOk);

or = Ok().Or(Err("error-message"));
Assert.True(or.IsOk);

or = Err("error-message").Or(Ok());
Assert.True(or.IsOk);

or = Err("error-message").Or(Err("second-error-message"));
Assert.True(or.IsErr);
Assert.Equal(Some("second-error-message"), or.ErrorMessage());
Or(Res) Combines two results: this and other as follows:
  • returns this if this is Ok;
  • returns other otherwise.
C#
var or = Ok().Or(Ok());
Assert.True(or.IsOk);

or = Ok().Or(Err("error-message"));
Assert.True(or.IsOk);

or = Err("error-message").Or(Ok());
Assert.True(or.IsOk);

or = Err("error-message").Or(Err("second-error-message"));
Assert.True(or.IsErr);
Assert.Equal(Some("second-error-message"), or.ErrorMessage());

See Also