Giter Club home page Giter Club logo

klass's Introduction

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 5.1 to 5.3.

API Documentation

The API documentation is generated using LDoc.

Links

Examples

local klass = require "klass"

local Base = klass:extend("Base")

Base.x = 1

function Base:init(x)
    self.x = x
end

function Base:__tostring()
    return self.__name..": "..tostring(self.x)
end

local 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: 1

print(t5.x) --> Base: 1

klass's People

Contributors

kaeza avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.