This example
debug.setmetatable(0,
{
__bnot = function(a) -- ~ operator
print("yay ".. a)
return a
end
})
print(~ (0))
print(~ (0.3))
print(~ (1))
print(~ (2))
print(~ (2.1))
Outputs the following
-1
yay 0.3
0.3
-2
-3
yay 2.1
2.1
I was expecting
yay 0
0
yay 0.3
0.3
yay 1
1
yay 2
2
yay 2.1
2.1
It looks like it is not called for integer values.
How do I override the not operator for all numbers?