So, I'm playing around with metatables, and on the Wiki, I learned this little trick:
local metatable= {
__index = {value= true}
}
local regulartable = setmetatable({}, metatable)
print(regulartable.value)
Prints "true" in the output.
I wanted to see if I could put multiple __index metamethods in the same metatable, so, in essence, I could have multiple pseudo "properties" of a table. I tried this:
local metatable= {
__index = {value= true},
__index = {secondvalue = false}
}
local regulartable = setmetatable({}, metatable)
print(regulartable.secondvalue, regulartable.value)
I noticed that with the second value set, the first value would be nil. I tried a few other things, but they all showed up as incorrect on the syntax checker, so they aren't worth mentioning here.
How do I set multiple __index metamethods in a single metatable?
