filterOrElse method
- bool f(
- R r
- L onFalse(
- R r
If f
applied on this Either as Right returns true
, then return this Either.
If it returns false
, return the result of onFalse
in a Left.
Implementation
Either<L, R> filterOrElse(bool Function(R r) f, L Function(R r) onFalse) =>
flatMap((r) => f(r) ? Either.of(r) : Either.left(onFalse(r)));