average method
Computes the average of all values. Values are created from this iterable's elements using select
.
Returns double.nan if empty, or if select
returns double.nan.
Example
final list = [('a', 1), ('b', 3), ('c', 5)];
list.average((e) => e.$2); // 3
Implementation details
Computing values is assumed to be cheap. Hence, values are recomputed each time rather than cached.
Implementation
@useResult double average(Select<E, num> select) => sum(select) / length;