maxBy<R extends Comparable<R>> method Null safety

T maxBy<R extends Comparable<R>>(
  1. R by(
    1. T item
    ),
  2. [T? ifNull]
)

Implementation

T maxBy<R extends Comparable<R>>(R by(T item), [T? ifNull]) {
  return maxByOrNull(by, ifNull) ??
      (throw IndexError(0, this, "maxBy while empty"));
}