sumBy method

num sumBy(
  1. num f(
    1. T
    )
)

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;
}