Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaeza/klass
Minimalistic class system for Lua.
https://github.com/kaeza/klass
lua
Last synced: 28 days ago
JSON representation
Minimalistic class system for Lua.
- Host: GitHub
- URL: https://github.com/kaeza/klass
- Owner: kaeza
- License: mit
- Created: 2017-07-06T23:50:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-06T02:47:02.000Z (about 5 years ago)
- Last Synced: 2024-11-08T10:54:32.410Z (2 months ago)
- Topics: lua
- Language: Lua
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Klass
Minimalistic class system for Lua.
## License
This program is free software released under a permissive license. You can
use it both in Free and closed source software. See `LICENSE.md` for details.## Requirements
* [Lua][Lua] 5.1 to 5.3.
## API Documentation
The API documentation is generated using [LDoc][LDoc].
## Links
* Download development version: [`.zip`][devzip], [`.tar.gz`][devtgz].
* [Project page][repo] at Github.## Examples
local klass = require "klass"
local Base = klass:extend("Base")
Base.x = 1
function Base:init(x)
self.x = x
endfunction Base:__tostring()
return self.__name..": "..tostring(self.x)
endlocal Derived = Base:extend("Derived")
Derived.x = 3
local t1 = Base()
local t2 = Base(2)
local t3 = Derived()
local t4 = Derived(4)
local t5 = Derived(t1)print(t1) --> Base: 1
print(t2) --> Base: 2
print(t3) --> Derived: 3
print(t4) --> Derived: 4
print(t5) --> Derived: Base: 1print(t5.x) --> Base: 1
[Lua]: https://lua.org
[LDoc]: https://github.com/stevedonovan/LDoc
[devzip]: https://github.com/kaeza/klass/archive/master.zip
[devtgz]: https://github.com/kaeza/klass/archive/master.tar.gz
[repo]: https://github.com/kaeza/klass