Method Where
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
Where<T>(Maybe<T>, Func<T, bool>)
Implements the LINQ where operation for the Maybe<T> monad, keeping the contained value only if it satisfies a predicate.
public static Maybe<T> Where<T>(this Maybe<T> value, Func<T, bool> predicate)
Parameters
valueMaybe<T>The Maybe<T> value to filter.
predicateFunc<T, bool>The predicate, which is run against the contained value if there is one.
Returns
- Maybe<T>
valueif it contains a value which satisfiespredicate, and a Maybe<T> containing no value otherwise.
Type Parameters
TThe type of the value contained in the monad to filter.
Remarks
predicate is run only when there is a value, so this
narrows a value which is there, and does not make one. It is also what lets
a query expression over a Maybe<T> have a where
clause.