Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Class declaration in Lua.
- Foo = {}
- -- constructor
- function Foo.new()
- return setmetatable({
- -- attributes
- xyzzy = 42
- }, {__index = Foo})
- end
- -- methods
- function Foo:bar()
- -- self is this instance
- print(self.xyzzy)
- end
- -- static methods
- function Foo.qux()
- print("Lua is awesome.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement