Hi, I’m confused on one thing.
local ClassMetamethods = {
__index = function(self, k)
print(self, k)
end,
}
local Class = setmetatable({}, ClassMetamethods)
Class.__index = Class
function Class.new()
return setmetatable({}, Class)
end
local object = Class.new()
local x = object.Test
The __index
function in ClassMetamethods
is passing Class
in for self
when I index object
. Shouldn’t it be passing in object
instead? Am I doing something wrong?