sum method
Returns the sum of all the values in this iterable, as defined by
addend
.
Returns 0 if this
is empty.
Example:
['a', 'aa', 'aaa'].sum((s) => s.length); // 6.
Implementation
num sum(num Function(E) addend) {
if (isEmpty) return 0;
return fold(0, (prev, element) => prev + addend(element));
}