So I am curious about how the self keyword is used with the : operator.
so I have this code
local z = {
a = 1,
test = function()
self.a = 2
end
}
z:test() // will error
where I get that error (unknown global self)
however if I just were to put in the paramter self into the function like so
local z = {
a = 1,
test = function(self)
self.a = 2
end
}
z:test()
I am curious to why I have to put that self keyword into the parameter even though I am not passing it, I am using the : operator. if I don’t use the f = function() syntax, and just use the regular function z:test() syntax I don’t need to put self in as a argument.