groupBy<K> method

Map<K, List<E>> groupBy<K>(
  1. K keyFunction(
    1. E
    )
)

Implementation

Map<K, List<E>> groupBy<K>(K Function(E) keyFunction) =>
    fold(
      <K, List<E>>{},
      (Map<K, List<E>> map, E element) =>
        map..putIfAbsent(
          keyFunction(element),
          () => <E>[]
        ).add(element)
    );