Well, you don't instantiate multiple instances of a module, like he does with Card and Player. His classes don't support inheritance, but inheritance is orthogonal to the concept of a class. So while they are limited and not idiomatic Lua, but I'd still say they're classes:Robin wrote:Yes. It's called modules, not classes. Technically, you don't have any classes in your code.
Side note: I saw some Lua code in a Corona app that did classes entire via closures. Very wasteful of memory, and not supporting inheritance, but allowing for truly private state. Something like:Wikipedia wrote:A class is a construct that is used as a blueprint to create instances of itself. A class defines constituent members which enable these class instances to have state and behavior. Data field members (member variables or instance variables) enable a class object to maintain state. Other kinds of members, especially methods, enable a class object's behavior.
Code: Select all
function Point_new(_x,_y)
return {
getPosition = function() return _x, _y end,
setPosition = function(x,y) _x, _y = x, y end,
}
end