fold<R> method
Reduces the list to a single value by iteratively combining each element of this list with an existing value.
Uses initialValue
as the initial value, then iterates through the
elements and updates the value with each element using the combine
function, as if by:
var value = initialValue;
for (E element in this) {
value = combine(value, element);
}
return value;
Example of calculating the sum of a list:
list.fold(0, (prev, element) => prev + element);
Implementation
@override
R fold<R>(R initialValue, R Function(R previousResult, T value) combine) =>
_list.fold(initialValue, combine);