OptTOr Method

Overload List

Or(FuncOptT) (lazy version) Combines two options: this and other as follows:
  • returns this if this is Some;
  • returns other otherwise.

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

C#
var or = Some(12).Or(Some(13));
Assert.Equal(Some(12), or);

or = Some(12).Or(None<int>());
Assert.Equal(Some(12), or);

or = None<int>().Or(Some(13));
Assert.Equal(Some(13), or);

or = None<int>().Or(None<bool>());
Assert.True(or.IsNone);
Or(OptT) Combines two options: this and other as follows:
  • returns this if this is Some;
  • returns other otherwise.

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

C#
var or = Some(12).Or(Some(13));
Assert.Equal(Some(12), or);

or = Some(12).Or(None<int>());
Assert.Equal(Some(12), or);

or = None<int>().Or(Some(13));
Assert.Equal(Some(13), or);

or = None<int>().Or(None<bool>());
Assert.True(or.IsNone);

See Also