Some and None
Lifting values and returning something instead of nothing.
Some<T>(T) -> Option<T>
Some<T>(T) -> Option<T>int number = 42;
// use a pure function to return a value as an Option<T>
Option<int> option = F.OptionF.Some(number);
// use the same function, but in my preferred style
using static F.OptionF;
Option<int> option = Some(value);
// use implicit operator - which calls F.OptionF.Some
Option<int> option = number;
// use an extension method - which calls F.OptionF.Some
Option<int> option = number.Some();if (option is Some<int> number)
{
Console.Write("The answer to the question is '{0}'.", number.Value);
}
// The answer to the question is '42'.None<T>(IMsg) -> Option<T>
None<T>(IMsg) -> Option<T>Some<T>(Func<T>, Handler) -> Option<T>
Some<T>(Func<T>, Handler) -> Option<T>Messages
True and False
Last updated