Skip to content

Instantly share code, notes, and snippets.

@TannerRogalsky
Forked from Uradamus/class_test.lua
Created April 7, 2014 16:24
Show Gist options
  • Save TannerRogalsky/10023534 to your computer and use it in GitHub Desktop.
Save TannerRogalsky/10023534 to your computer and use it in GitHub Desktop.
local Class = setmetatable({
new = function(arg1, arg2, arg3)
local obj = {}
obj.var1 = arg1
obj.var2 = arg2
obj.var3 = arg3
obj.out = function (self, arg)
print(self[arg])
end
return obj
end
}, {__call = function(_, ...) return Class.new(...) end})
test = Class("One", "Two", "Three")
test:out("var1")
print(test.var1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment