I'm looking for a way in Lua 5.1 to compare with metatables, so I can compare any value with a table. If that value is in the table it returns true, and false if it is not in the table. like the following.
if table == string then
-- does something if string is in the table
end
I know that the __eq
is used, but the reference manual stats something about making sure that the 2 be the same type and have the same __eq
function. To do this I would need to overcome that limitation and I do not know how, or even if it is even possible.
+
,-
,*
,/
,%
,^
,<
orif table(string) then
. - Egor Skriptunofftable == string
is shameless operator abuse, like redefining*
to mean subtraction. Add a "contains" method to your table (or it's metatable). - Mud