limit method

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

Restrict value from min to max.

Implementation

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