average method

double average()

Returns the average of all elements in the iterable.

Example:

[1, 2, 3].average(); // 2.0

Implementation

double average() {
  if (isEmpty) return 0.0;
  return sum() / length;
}