What is the cleanest way to get the sum of numbers in a collection/list in Dart?

Dart iterables now have a reduce function (https://code.google.com/p/dart/issues/detail?id=1649), so you can do a sum pithily without defining your own fold function:

var sum = [1, 2, 3].reduce((a, b) => a + b);

Leave a Comment