Accumulator<T, U> typedef
Accumulator<T, U> =
U Function(U, T)
A function used to accumulate values in reduction operations.
Takes an accumulator of type U
and a current value of type T
,
returning a new accumulator.
{@tool snippet}
final Accumulator<int, int> sum = (acc, value) => acc + value;
final total = [1, 2, 3, 4].reduce((a, b) => sum(a, b));
print(total); // 10
{@end-tool}
Implementation
typedef Accumulator<T, U> = U Function(U, T);