bestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish · 5 days agoThe meaning of thisimagemessage-square71fedilinkarrow-up1535arrow-down116
arrow-up1519arrow-down1imageThe meaning of thisbestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish · 5 days agomessage-square71fedilink
minus-squareDie Martin Die@sh.itjust.workslinkfedilinkarrow-up5·edit-23 days 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 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. Edit: some typos
minus-squarejsomae@lemmy.mllinkfedilinkarrow-up3·4 days agoI don’t see how what you said is inconsistent with me saying “self” is special in lua. Note that I did not say it’s a keyword.
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 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.Edit: some typos
I don’t see how what you said is inconsistent with me saying “self” is special in lua. Note that I did not say it’s a keyword.
Derp, I misread.