As I understand from docs, we don't have classes in Lua. Lua does not have the concept of class; each object defines its own behavior and has a shape of its own.
So a simple emulation of classes in Lua, following the lead from prototype-based languages, such as Self and NewtonScript would be something like.
function Account:new (o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
What I don't understand here is what does o = o do and why do we need to use setmetadatatable and the next line index = self.
What does it do and why do we need them?
Also self.o = o was pretty much understood, but o = o, wouldn't that create any conflict?