lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

There is something I don't understand about the way __index and
metamethods work. The way I understand, the "." operator looks in the
table itself and the ":" operator looks directly in the metatable. If
so, then why is it necessary to say:

    MyClass.__index = MyClass

for you to be able to use ":"?

If ":" looks right in the metatable, then it shouldn't be needed. To
me it seems like what it would do is let you call metamethods using
the "." operator, but it doesn't work that way for some reason.