Posted 15 November 2013 - 05:13 PM
What's the benefit of using Meta Tables with the Object Oriented aspect of lua?
For example,
Object Class
That's object oriented, and works fine.
I personally am not a big fan of metatables and try to avoid them wherever possible.
For example,
Object Class
objectClass = {}
objectClass.new = function(...)
newObject = {}
newObject.getVariable = function(self)
return self.variable
end
return newObject
end
return objectClass
Main File
object = require('objectClass') -- The way I do it in love2d
myObject = object.new(...)
myObject:getVariable()
...etc
That's object oriented, and works fine.
I personally am not a big fan of metatables and try to avoid them wherever possible.