예제 #1
0
 /// <summary>
 /// Projects the current type of option into a new type of option and flattens the result (Linq SelectMany).
 /// </summary>
 /// <typeparam name="R">The type of the option returned by the transform function.</typeparam>
 /// <param name="f">A transform function to apply to the current option.</param>
 public OptionF <R> Bind <R>(Func <T, OptionF <R> > f)
 {
     if (this.IsNone)
     {
         return(OptionF <R> .None());
     }
     else
     {
         return(f(this.Value));
     }
 }
예제 #2
0
 /// <summary>
 /// Projects the current type of option into a new type of option (Linq Select).
 /// </summary>
 /// <typeparam name="R">The type of the option returned by the transform function.</typeparam>
 /// <param name="f">A transform function to apply to the current option.</param>
 public OptionF <R> Map <R>(Func <T, R> f)
 {
     if (this.IsNone)
     {
         return(OptionF <R> .None());
     }
     else
     {
         return(OptionF <R> .Some(f(this.Value)));
     }
 }