In Lua, indexing a table with a table as a key __eq metadata call?

I am wondering if table[key], where keyis the table with the metatheme, will call the metatheat __eq. For example, if the table has a key "a", and the metatet __eq returns true, if "a" is compared with the metathema, does indexing the table with the table return the value "a"?

+4
source share
1 answer

No, indexing uses raw equality: http://www.lua.org/manual/5.2/manual.html#2.4

You should consider explicitly converting objects to their string representation before indexing, rather than relying on implicit metamethods.

+4

Source: https://habr.com/ru/post/1537224/


All Articles