PutridParrot.Options/OptionalExtensions.cs
/// <summary>
/// If the Optional has a value and the predicate returns true then 
/// returns the Optional otherwise returns an Optional.None
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="optional"></param>
/// <param name="predicate"></param>
/// <returns></returns>
If the Optional has a value and the predicate returns true then
returns the Optional otherwise returns an Optional.None
If the Optional has a value and the predicate returns true then returns the Optional otherwise returns an Optional . None
public static Optional<T> If<T>(this Optional<T> optional, Predicate<T> predicate)
        {
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }
            return optional.IsSome && predicate(optional.Value) ?
                optional : Optional<T>.None;
        }
public static Optional < T > If < T > ( this Optional < T > optional , Predicate < T > predicate ) { if ( predicate == null ) { throw new ArgumentNullException ( nameof ( predicate ) ) ; } return optional . IsSome && predicate ( optional . Value ) ? optional : Optional < T > . None ; }
If the Optional has a value and the predicate returns true then
returns the Optional otherwise returns an Optional.None
If the Optional has a value and the predicate returns true then returns the Optional otherwise returns an Optional . None
None
Optional<T>
this
predicate
Predicate<T>
None
optional
None
typeparam
None