Created
July 1, 2017 16:16
-
-
Save blm768/bb10fefc723305153588897cb01a6d66 to your computer and use it in GitHub Desktop.
Lua class code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class = {} | |
function Class:new(super) | |
local class = {} | |
if super ~= nil then | |
local class_mt = {__index = super} | |
setmetatable(class, super) | |
end | |
local object_mt = {__index = class} | |
class.new = function(self, ...) | |
local object = {} | |
setmetatable(object, object_mt) | |
if object.initialize then | |
object:initialize(...) | |
end | |
return object | |
end | |
return class | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment