count method

int count(
  1. bool test(
    1. T element
    )
)

Counts the number of elements that satisfy the test.

Example:

[1, 2, 3, 4].count((i) => i % 2 == 0); // 2

Implementation

int count(bool Function(T element) test) {
  var c = 0;
  for (var element in this) {
    if (test(element)) c++;
  }
  return c;
}