Skip to content

Instantly share code, notes, and snippets.

@Uradamus
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Uradamus/10023248 to your computer and use it in GitHub Desktop.
Save Uradamus/10023248 to your computer and use it in GitHub Desktop.
Simple example of a combination class definition / construction function in Lua.
function Class (arg1, arg2, arg3)
local obj = {}
obj.var1 = arg1
obj.var2 = arg2
obj.var3 = arg3
function obj:out (arg)
print(self[arg])
end
return obj
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