Lua POO

hi guys, I’m new around here, I would like to know how object-oriented programming in lua ? 

Thanks for the answers :smiley:

No oop itself in lua. However you can use metatables which can be used to create oop-like behaviour.

In addition to metatables, Lua “objects” are nothing more than Lua tables that can contain various table entries that can be variables that are equivalent to object “attributes”

local myObject = {}

myObject.name = “Fred”

It can also contain function references that are like methods:

myObject:setName = function(name)

     self.name = name

end

Now there are no real concepts of private attributes/methods, everything is exposed.   

No oop itself in lua. However you can use metatables which can be used to create oop-like behaviour.

In addition to metatables, Lua “objects” are nothing more than Lua tables that can contain various table entries that can be variables that are equivalent to object “attributes”

local myObject = {}

myObject.name = “Fred”

It can also contain function references that are like methods:

myObject:setName = function(name)

     self.name = name

end

Now there are no real concepts of private attributes/methods, everything is exposed.