OptionExtensionsSomeIfNotnullT Method
Creates an option of
T as Some variant with the given
value.
However, if the
value is null, it will map into None.
string name = null;
static string? GetName(int id)
=> id == 0 ? "Mr Crabs" : null;
Opt<string> optName = GetName(0).SomeIfNotnull();
Assert.Equal(Some("Mr Crabs"), optName);
optName = GetName(42).SomeIfNotnull();
Assert.True(optName.IsNone);
Namespace: Orx.Fun.OptionAssembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
public static Opt<T> SomeIfNotnull<T>(
this T value
)
where T : class
- value T
- A nullable value of T to be converted to the option type.
- T
[Missing <typeparam name="T"/> documentation for "M:Orx.Fun.Option.OptionExtensions.SomeIfNotnull``1(``0)"]
OptTIn Visual Basic and C#, you can call this method as an instance method on any object of type
T. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).