How to use a class's constructor on Lua
We add the following bits of code to our class: setmetatable(MyClass, { __call = function (cls, ...) return cls.new(...) end, }) function MyClass.new(init) local self = setmetatable( »
We add the following bits of code to our class: setmetatable(MyClass, { __call = function (cls, ...) return cls.new(...) end, }) function MyClass.new(init) local self = setmetatable( »
Using the sugar syntax : on Lua will allow us to access to the self table instance and for consecuent all methods and variables inside that specific »