clamp method

Decimal clamp(
  1. Decimal lowerLimit,
  2. Decimal upperLimit
)

Clamps this to be in the range lowerLimit-upperLimit.

Implementation

Decimal clamp(Decimal lowerLimit, Decimal upperLimit) => this < lowerLimit
    ? lowerLimit
    : this > upperLimit
        ? upperLimit
        : this;