sum property
T
sum
The sum of all elements of the set of numbers
Implementation
T get sum {
if (isEmpty) {
final String type = T.toString();
if (type == 'int') return 0 as T;
if (type == 'double') return 0.0 as T;
if (type == 'num') return 0 as T;
}
if (length == 1) return first;
num sum = 0;
for (final T element in this) {
sum += element;
}
return sum as T;
}