Returns the sum of a list, after mapping each element to a number using the provided function.

Use to map each element to the numeric value returned by fn, Iterable.reduce() to sum the values.


num sumBy<T>(List<T> lst, num Function(T) fn) {
  return a, num b) => a + b);


sumBy([ {'n': 4}, {'n': 2}, {'n': 8}, {'n': 6} ], (o) => o['n']); // 20