sumBy method

int sumBy(
  1. int selector(
    1. T
    )
)

Example:

[1, 3, 7].sumBy((n) => n);                 // 11
['hello', 'world'].sumBy((s) => s.length); // 10

Implementation

int sumBy(int Function(T) selector) {
  return this.validate().map(selector).fold(0, (prev, curr) => prev + curr);
}