split method

Tuple2<List<T>, List<T>> split(
  1. bool on(
    1. T
    )
)

Splits the elements according to on. Items for which on is true will be stored in Tuple2.item1, other items in Tuple2.item2

Implementation

Tuple2<List<T>, List<T>> split(bool Function(T) on) {
  final left = <T>[];
  final right = <T>[];
  forEach((element) {
    if (on(element)) {
      left.add(element);
    } else {
      right.add(element);
    }
  });

  return Tuple2(left, right);
}