#OOP
1 messages · Page 1 of 1 (latest)
same bro same
skill issue
lol
you need to understand how metatables work
__index is one of the metamethods that exists
__index can be either a table or a function that receives self, key
basically the use of __index is this:
you got your table set to a metatable:
local t = setmetatable({}, metaTable);
local k = t["test"]
imagine metaTable has a __index set to another table, what will happen is this:
- Will try to see if the key exists on the table
- If it does not exists, it will get the metatable of the table and if it owns the
__indexmetamethod it will try to find the key in the table of the index metamethod
\_\_index \_\_index
ty Ill use that for next lol
if ur wondering how i did that: \\\_\\\_index