sum
sum(numbers: List<Integer>) : Integer
sum(numbers: List<Float>)   : Float
The sum of a list of integer numbers or a list of floating-point numbers.
- For example, on integers, sum([1, 2, 3])equals6.
- Likewise, on floats, sum([1.1, 2.1, 3.1])equals6.300000000000001.- Keep in mind that floating-point arithmetic is generally not precise!
 
- You can define a list in various ways, not just as a list of literal numbers. See List for more
detail on working with lists.
- Importantly, a list's elements must all be of the same type.
As such, sum([1.1, 2, 3.1])has a type-error since the list is not well-formed. The fix is to replace integer2with2.0or2.to have it be treated as a float.
- You can use intandfloatto convert to integers and to floats, respectively.
 
- Importantly, a list's elements must all be of the same type.
As such,