Exists
Returns true if the given predicate functions return true when applied to either value. Otherwise, returns false.
Parâmetros
Retorno
Func<TRight, bool> predicateWhenRight
Func<TLeft, bool> predicateWhenLeft
Either<TLeft, TRight> either
bool
Usage
When the Either
IsLeft
, the result will be the return of predicateWhenLeft
function, otherwise will be the return of predicateWhenRight
.
When Either IsRight and predicate returns true
When Either IsLeft and predicate returns true
When Either IsRight and predicate returns false
One sided approach
You can also use the ExistsLeft
and ExistsRight
to produce the same results, but with these methods the predicated is applied just to one of the possible values.
When the target type is different from Either
current value the result always will be false
ExistsRight when Either IsRight
ExistsLeft when Either IsRight
Last updated
Was this helpful?