ResTOr(ResT) Method

Combines two results: this and other as follows:
  • returns this if this is Ok;
  • returns other otherwise.

In other words, this is a flattened alternative to UnwrapOr(T).

C#
var or = Ok(42).Or(Ok(7));
Assert.Equal(Ok(42), or);

or = Ok(42).Or(Err<int>("error-message"));
Assert.Equal(Ok(42), or);

or = Err<int>("error-message").Or(Ok(7));
Assert.Equal(Ok(7), or);

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

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public Res<T> Or(
	Res<T> other
)

Parameters

other  ResT
Other result to combine with.

Return Value

ResT

See Also