Table of Contents

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

value Maybe<T>

The Maybe<T> value to filter.

predicate Func<T, bool>

The predicate, which is run against the contained value if there is one.

Returns

Maybe<T>

value if it contains a value which satisfies predicate, and a Maybe<T> containing no value otherwise.

Type Parameters

T

The 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.