fromPredicateK<L, R> function
Either<L, R> Function(R value)
fromPredicateK<L, R>(
- bool predicate(
- R value
- L orElse(
- R value
Wrapper for fromPredicate, that returns a function which transforms a value into an Either.
final transform = fromPredicateK(
(int number) => number > 1,
(_) => 'number too small',
);
expect(transform(2), right(2));
expect(transform(0), left('number too small'));
Implementation
Either<L, R> Function(R value) fromPredicateK<L, R>(
bool Function(R value) predicate,
L Function(R value) orElse,
) =>
(r) => fromPredicate(r, predicate, orElse);