partition method Null safety
- Predicate<
E> test
Splits this collection into pair (Tuple2) of lazy iterables,
where item1 contains elements for which test yields true,
while item2 contains elements for which test yields false.
Example:
[1, 0, -3, 4, -6].partition((n) => n.isNegative) // => ([-3, -6], [1, 0, 4])
Implementation
Tuple2<Iterable<E>, Iterable<E>> partition(Predicate<E> test) {
final itrPositive = this?.where(test) ?? Iterable.empty();
final itrNegative = whereNot(test);
return Tuple2(itrPositive, itrNegative);
}