sumBy method
Sum by f
of all elements in the list.
Returns 0
if the list is empty and f
returns null
.
Implementation
num sumBy(num Function(T) f) {
num sum = 0;
for (final item in this) {
final value = f(item);
sum += value;
}
return sum;
}