aggregate<R> method
For each group the operation
is applied to the elements of that group
sequentially.
The previous accumulated value is passed and the current element. The result per group is stored in a new map.
The key for each element is provided by the [](T element)
operator.
final numbers = [3, 4, 5, 6, 7, 8, 9];
final aggregated = numbers
.groupingBy((value) => value % 3)
.aggregate((key, accumulator, element, first) {
return first ? '$key:$element' : '$accumulator-$element';
});
print(aggregated.values); // (0:3-6-9, 1:4-7, 2:5-8)
Implementation
Map<K, R> aggregate<R>(AggregateOperation<T, K, R> operation) {
return aggregateTo({}, operation);
}