What I am asking is if, there is a use case for doing something like this
not (x == y)
Isn’t that reinventing the wheel for
x != y
And I see it happening with other operators.
not (x < y)
-- literally
x >= y
not (x > y)
-- literally
x <= y
Maybe I am underestimating it but it seems pointless to me. And I highly doubt it is readability because x is not equal to y is much clear than not x is equal to y.
There are a few very technical cases where the distinction matters, mainly NaN values. NaN values are generated when you divide 0 by 0 or access the .Magnitude of a 0, 0, 0 Vector3. For example, if you want to consider NaN out of range when doing a range check, then:
local function inRange(value, min, max)
return value > min and value < max
end
will return false for a NaN value, however:
local function inRange(value, min, max)
if value < min then
return false
end
if value > max then
return false
end
return true
end
will return true when passed a NaN value.
If you want to keep the style of the second function, then you could use not (value >= min) instead of value < min.