Group<E> class

A namespace for functions that group an Iterable's elements.

To access Group, call the GroupableIterable.group extension getter on an iterable.

These functions are intended for 1:N mappings. See Iterables.associate for associating one element by one key (1:1).

Example

final iterable = [('a', 1), ('a', 2), ('b', 3)];
final aggregate = iterable.group.lists(by: (e) => e.$1);

print(aggregate); // {'a': [('a', 1), ('a', 2)], 'b': [('b', 3)]}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

by<K, V>(Select<E, K> by, {required V as(V? previous, E current)}) Map<K, V>
Groups the iterable's elements by keys returned by by before being folded using as.
lists<K>({required Select<E, K> by}) Map<K, List<E>>
Groups the iterable's elements in lists by keys returned by by.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sets<K>({required Select<E, K> by}) Map<K, Set<E>>
Groups the iterable's elements in sets by keys returned by by.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited