PutridParrot.Options/OptionExtensions.cs
/// <summary>
/// If the Option has some value then call the
/// supplied function to return a result else
/// return a default/alternate value
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <param name="option"></param>
/// <param name="someValue"></param>
/// <param name="noneValue"></param>
/// <returns></returns>
If the Option has some value then call the
supplied function to return a result else
return a default/alternate value
If the Option has some value then call the supplied function to return a result else return a default / alternate value
public static TResult Match<T, TResult>(this Option<T> option,
            Func<T, TResult> someValue,
            TResult noneValue = default(TResult))
        {
            if (someValue == null)
            {
                throw new ArgumentNullException(nameof(someValue));
            }
            return option is Some<T> some ? someValue(some.Value) : noneValue;
        }
public static TResult Match < T , TResult > ( this Option < T > option , Func < T , TResult > someValue , TResult noneValue = default ( TResult ) ) { if ( someValue == null ) { throw new ArgumentNullException ( nameof ( someValue ) ) ; } return option is Some < T > some ? someValue ( some . Value ) : noneValue ; }
If the Option has some value then call the
supplied function to return a result else
return a default/alternate value
If the Option has some value then call the supplied function to return a result else return a default / alternate value
None
Option<T>
this
someValue
Func<T, TResult>
None
noneValue
TResult
None
option
None
typeparam
None
typeparam
None