Lua "classes" or closures as classes?
Lua "classes" or closures as classes?
![](https://lemdro.id/pictrs/image/bc9faa12-7695-4160-b99e-b26d33ace1ce.png?format=webp&thumbnail=128)
![](https://lemdro.id/pictrs/image/bc9faa12-7695-4160-b99e-b26d33ace1ce.png?format=webp)
Hey all,
I'm learning Lua and come from a Java background, and have been diving deep into Lua "classes".
Realizing that a Lua "class" is just some clever syntactic sugar, and lacks encapsulation, I've found that closures can act like a Java class and protect it's state. An added bonus is my muscle memory won't struggle with : vs . for function calls, a pitfall I've already wasted time debugging.
I'm new to all this though, is there anything I'm missing? Is a Lua "class" with self and : a better choice than using a closure like a class?