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

Returns the sum of all numeric values from a set.

Empty sets return 0 converted to the set item type.

ints = {10, 20, 30}
print(sum(ints))   # 60

doubles = {10.1, 20.2, 30.3}
print(sum(doubles))   # 60.6
Parameters
ParameterDescription
valuesThe set to sum.
Returns

The accumulated total with the same numeric type as the set items.

Throws
  • NullException if values is null at runtime; a statically null argument is rejected at compilation with TypeError.