3 ms·
To elaborate, Lua has special syntax for defining and calling methods vs unbound functions. In Lua, function woot:donk() ... end woot:donk() is equiva
by extension 15y ago
To elaborate, Lua has special syntax for defining and calling methods vs unbound functions. In Lua,
function woot:donk() ... end
woot:donk()
is equivalent to
woot.donk = function(self) ... end
woot.donk(woot)
and when you define a function normally e.g.
function() ... end
there is no self parameter, thus the one from the parent scope is captured. The flaw with JS, really, is that it forces every function to be a method, and doesn't let you express whether you are defining one or the other.
(think I got this right, my Lua is a bit rusty)
- LeafStorm 15y agoYep, that's pretty much it. And the woot:donk() notation will only evaluate what's left of the colon once, which is nice.