RosettaCodeData/Task/Call-an-object-method/Lua/call-an-object-method-1.lua

5 lines
147 B
Lua

local object = { name = "foo", func = function (self) print(self.name) end }
object:func() -- with : sugar
object.func(object) -- without : sugar