Returns the sum value of a list of numbers.

Use Iterable.reduce() to sum all the numbers in a list.

代码实现

num sum(List<num> nums){
  return nums.reduce((num a, num b) => a + b);
}

使用样例

sum([1, 2, 3, 4]); // 10