public static T?OrNull <T>(this Opt <T> opt, T?otherVal) where T : struct { if (opt.IsSome) { return(opt.Val); } return(otherVal); }
public static Opt <V> Ap <T, U, V>(Func <T, U, V> f, Opt <T> v1, Opt <U> v2) { if (v1.IsNone) { return(Opt <V> .None()); } if (v2.IsNone) { return(Opt <V> .None()); } return(Opt <V> .Some(f(v1.Val, v2.Val))); }
public static Opt <T> Some(T val) { if (val == null) { throw new ArgumentNullException(nameof(val), "Cannot supply a NULL value to the Opt.Some() constructor."); } var opt = new Opt <T> { IsSome = true, _val = val }; return(opt); }
public static Opt <T> Some <T>(T val) { return(Opt <T> .Some(val)); }
public static Opt <T> None <T>() { return(Opt <T> .None()); }