klyn.Application.sum
method
public static sum<T extends AbstractNumber>(values as IList<T>) as T:
Description

Returns the sum of all numeric values from a read-only list.

Empty lists return 0 converted to the list item type.

ints = [10, 20, 30]
print(sum(ints))   # 60

doubles = [10.1, 20.2, 30.3]
print(sum(doubles))   # 60.6
Parameters
  • values The read-only list to sum.
Returns

The accumulated total with the same numeric type as the input values.