maxOf function

int maxOf(
  1. Iterable<int> values
)

Finds the maximum value in an iterable of integers.

Returns 0 for empty iterables.

Example:

maxOf([3, 7, 2, 9]); // 9
maxOf([]); // 0

Implementation

int maxOf(Iterable<int> values) {
  var max = 0;
  for (final v in values) {
    if (v > max) max = v;
  }
  return max;
}