average method

double average()

Calculates the average (mean) of all numbers in the list.

Returns 0 if the list is empty.

Implementation

double average() {
  return (length > 0) ? sum() / length.toDouble() : 0.0;
}