avgOf method

double avgOf(
  1. GetValue<E, int> getVal
)

Returns the average value of int values by elements.

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

If no elements, return 0.

Implementation

double avgOf(GetValue<E, int> getVal) {
  final count = length;
  return count > 0 ? sumOf(getVal) / count : 0;
}