limit method

int limit(
  1. int min,
  2. int max
)

Implementation

int limit(int min, int max) {
  if (this > max) return max;
  if (this < min) return min;
  return this;
}