Either<L, R>.fromPredicate constructor
Either<L, R>.fromPredicate (
- R r,
- bool predicate(
- R r
- L onFalse(
- R r
If calling predicate with r returns true, then return Right(r).
Otherwise return Left containing the result of onFalse.
Implementation
factory Either.fromPredicate(
R r, bool Function(R r) predicate, L Function(R r) onFalse) =>
predicate(r) ? Either.of(r) : Either.left(onFalse(r));