partitionEithers<E, A> static method

Tuple2<List<E>, List<A>> partitionEithers<E, A>(
  1. List<Either<E, A>> list

Extract all the Left and Right values from a List<Either<E, A>> and return them in two partitioned List inside Tuple2.


static Tuple2<List<E>, List<A>> partitionEithers<E, A>(
    List<Either<E, A>> list) {
  final resultListLefts = <E>[];
  final resultListRights = <A>[];
  for (var i = 0; i < list.length; i++) {
    final e = list[i];
    if (e is Left<E, A>) {
    } else if (e is Right<E, A>) {
    } else {
      throw Exception(
        "[fpdart]: Error when mapping Either, it should be either Left or Right.",

  return Tuple2(resultListLefts, resultListRights);