4 ms·
Lua: local debug = require "debug" -- in case 5.2 debug.setmetatable(1, {__tostring=function(n) return ("%g"):format(n+1) end}) print(2+
by whoopdedo 12y ago
Lua:
local debug = require "debug" -- in case 5.2
debug.setmetatable(1, {__tostring=function(n)
return ("%g"):format(n+1)
end})
print(2+2)
Trying to make 2+2==5 evaluate as true is a lot harder. Although Lua lets you define a custom + operator, it's a fallback not an override.