sum method

num sum()

Returns the sum of all elements in the iterable.

Example:

[1, 2, 3].sum(); // 6

Implementation

num sum() {
  return fold(0, (prev, el) => prev + el);
}