How would I be able to find if a number was within a certain range? (ex if -2 is within -3 and 3)
Thanks,
RGF
How would I be able to find if a number was within a certain range? (ex if -2 is within -3 and 3)
Thanks,
RGF
could you do
local num = -2
local minNum = -3
local maxNum = 3
if num > minNum and num < maxNum then
print("e")
end
you could use >= and <= if you want it to print if they’re equal to the minNum and maxNum too
you can do one of these:
way 1:
local min = 1
local max = 5
local number = 2 -- number
if num < max and num > min then
--do something
end
way 2:
local range = NumberRange.new(1, 5)
local num = 2
if num == range then
--do something
end
The second example wouldn’t work.
local Range = NumberRange.new(1, 5)
if Range.Min < math.pi and math.pi < Range.Max then
print("Hello world!")
end