Just want to point something out in the first version, I think you’re not properly setting the __index
metamethod of the DogClass, so in the first example, some bugs may occur.
Also, this thread might help you out if you’re a beginner in OOP: All about Object Oriented Programming
There’s also a handy module that you can use to make your OOP experience easier:
Class++ | Classes and OOP made easy and powerful with Access Specifiers, function overloading and more!