average property

double get average

Returns the average of a List<num>. Returns 0 if empty.

Implementation

double get average {
  if (isEmpty) return 0;
  if (this is! List<num>) {
    throw UnsupportedError('average is only supported on List<num>');
  }
  return (this as List<num>).fold<double>(0.0, (acc, e) => acc + e) / length;
}