sumOf method

int sumOf(
  1. GetValue<E, int> getVal
)

Returns sum of int values by elements.

getVal should return value for sum up. It can be property of element, or any another value by element.

Implementation

int sumOf(GetValue<E, int> getVal) => fold(0, (sum, e) => sum + getVal(e));