OptionExtensionsSomeIf Method

Overload List

SomeIfT(Boolean, T) 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);
SomeIfT(Boolean, FuncT) Lazy-in-evaluating-value counterpart of SomeIfT(Boolean, T).

See Also