minus-squareDie Martin Die@sh.itjust.workstoProgrammer Humor@lemmy.ml•The meaning of `this`linkfedilinkarrow-up1·10 hours agoKinda. Lua defines it implicitly only when you use the function foo:bar(a, b, c) -- note the colon syntactic sugar, which gets translated to function foo.bar(self, a, b, c)` -- note the period In all other cases, self is a regular variable name. You can even redeclare a new local with that name even when the old one is in scope. linkfedilink
Kinda.
Lua defines it implicitly only when you use the
function foo:bar(a, b, c) -- note the colon
syntactic sugar, which gets translated to
function foo.bar(self, a, b, c)` -- note the period
In all other cases,
self
is a regular variable name. You can even redeclare a new local with that name even when the old one is in scope.