OptionExtensionsSomeIfT(Boolean, T) Method

Creates a result of T as Some variant with value value if the someCondition holds. Otherwise, it will return the None variant.
C#
string team = "secret";
int score = 42;

Opt<string> winner = SomeIf(score > 30, team);
Assert(winner == Some(team));

Opt<string> loser = SomeIf(score < 40, team);
Assert(loser.IsNone);

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public static Opt<T> SomeIf<T>(
	bool someCondition,
	T value
)

Parameters

someCondition  Boolean
Condition that must hold for the return value to be Some(value).
value  T
Underlying value of the Some variant to be returned if someCondition holds.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:Orx.Fun.Option.OptionExtensions.SomeIf``1(System.Boolean,``0)"]

Return Value

OptT

See Also