max method

Option<T> max()

Returns the maximum element of an iterator.

Implementation

Option<T> max() {
  if (!moveNext()) {
    return None;
  }
  var max = current;
  while (moveNext()) {
    if (current.compareTo(max) > 0) {
      max = current;
    }
  }
  return Some(max);
}