in Range Or
Returns this number if it's within the specified range (inclusive), or the default value otherwise.
This function checks if the current number falls between the min and max values. If it does, the current number is returned. Otherwise, the default number is returned.
Example:
val age = 25
val validAge = age.inRangeOr(18, 65, 18) // validAge will be 25
val temperature = 10
val adjustedTemp = temperature.inRangeOr(15, 30, 20) // adjustedTemp will be 20Content copied to clipboard
Return
This number if it's in the range min, max, or default otherwise.
Parameters
min
The minimum value of the range (inclusive).
max
The maximum value of the range (inclusive).
default
The value to return if this number is not within the specified range.