Dart Iterale reduce()

Dart Iterale reduce()

·

1 min read

reduce():

  • The reduce() method reduces a collection of elements to a single value by iteratively combining elements using a combine() function.

  • Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.

Example:

void main() {
  List<int> numbers = [1, 2, 3, 4, 5];
  int sum = numbers.reduce((value, element) => value + element);
  print(sum); // Output: 15
}
15

Exited.