sum method

int sum()

Returns the sum of all elements.

Example:

[2, 6, 4, 8].sum(); // 20

Implementation

int sum() => sumBy((n) => n);