Answer the question
In order to leave comments, you need to log in
Which code option would be better?
I saw on the Internet two options for implementing OOP
First:
oop = {}
function oop:new()
local oop = {}
setmetatable(oop, self)
self.__index = self; return oop
end
function oop:draw()
--какой-нибудь код
end
function oop:update(dt)
--какой-нибудь код
end
return oop
oop = {}
function oop.new()
loсal oop = {
update = function (self, dt)
--какой-нибудь код
end,
draw = function (self)
--какой-нибудь код
end
}
return oop
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question