500 posts
Posted 02 December 2013 - 08:05 PM
Alright so I have this code:
local t = setmetatable({}, {__eq = function(left, right) print("hi") return true end})
print(t == 5)
But for some reason it won't print "hi", does anyone have an explanation? Probably something dumb that I missed :/
Edited on 02 December 2013 - 08:28 PM
125 posts
Location
Chunk 0
Posted 02 December 2013 - 09:17 PM
This might help.
http://lua-users.org...8/msg00469.html"'eq': the == operation. The function getcomphandler defines how Lua chooses a
metamethod for comparison operators. A metamethod only is selected when both
objects being compared have the same type and the same metamethod for the
selected operation."
Edited on 02 December 2013 - 08:18 PM
500 posts
Posted 02 December 2013 - 09:22 PM
This might help.
http://lua-users.org...8/msg00469.html"'eq': the == operation. The function getcomphandler defines how Lua chooses a
metamethod for comparison operators. A metamethod only is selected when both
objects being compared have the same type and the same metamethod for the
selected operation."
That's really weird functionality (suppose you wanted your object to be equal to the string "Hello" or something), but I guess that's how it is :/.