clamp method

  1. @override
Int32 clamp(
  1. Object lowerLimit,
  2. Object upperLimit
)
override

Clamps this integer to be in the range lowerLimit - upperLimit.

Implementation

@override
Int32 clamp(Object lowerLimit, Object upperLimit) {
  if (this < lowerLimit) {
    if (lowerLimit is IntX) return lowerLimit.toInt32();
    if (lowerLimit is int) return Int32(lowerLimit);
    throw ArgumentError(lowerLimit);
  } else if (this > upperLimit) {
    if (upperLimit is IntX) return upperLimit.toInt32();
    if (upperLimit is int) return Int32(upperLimit);
    throw ArgumentError(upperLimit);
  }
  return this;
}