isInRange method
Checks if the Rational value is within the specified range.
Determines if this Rational is between min and max.
- If
inclusiveistrue, the range is inclusive, meaning the method returnstrueif the value is equal tominormax. - If
inclusiveisfalse, the range is exclusive, meaning the method returnstrueonly if the value is strictly betweenminandmax.
Parameters:
min: The lower bound of the range.max: The upper bound of the range.inclusive: A boolean indicating whether the range is inclusive. Defaults totrue.
Returns:
trueif the Rational is within the specified range, according to theinclusiveflag.falseotherwise.
Implementation
bool isInRange(Rational min, Rational max, {bool inclusive = true}) {
assert(min <= max);
if (inclusive) {
return this >= min && this <= max;
} else {
return this > min && this < max;
}
}