Skip to content
github-actions[bot] edited this page Aug 23, 2024 · 1 revision

creates new class prototypes from a base
creates the __super() method and __extendee property in the class prototype

Lua
local class, extend, new = require("classjs")("class", "extend", "new");


class "Base" {
    constructor = function(self, name)
        self.Name = name;
    end,

    Test = function(self)
        return string.lower(self.Name)                            
    end,

    Type = 1
}


local Example = extend "Base" "Example" {
    constructor = function(self, name)
        self.__super(name);
    end,

    Type = 2
}


local pim = new "Example"("Pim");

print(pim.Name); -- "Pim"
print(pim.Type); -- 2
print(pim.Test()); -- "pim"

Type:

  • Function

Returns:

Sources:

Arguments:

  • base name String
    name of the class to extend from

  • name String
    name of the class

  • prototable Table
    prototype data used for the class's properties




classjs docs

Home | Lib


Keywords

🛈 class

🛈 extend

🛈 new

Methods

🛈 isa()

🛈 getclass()

🛈 Prototype

🛈 new()

🛈 __isa()

🛈 __super()

🛈 __name

🛈 __instances

🛈 __prototype

🛈 __extendee

🛈 __class

🛈 PrototypeItem

🛈 new()

🛈 __value

🛈 __parent

🛈 __writable

🛈 __configurable

🛈 __enumerable

🛈 Object

🛈 defineProperties()

🛈 defineProperty()

🛈 entries()

🛈 getOwnPropertyDescriptor()

🛈 getOwnPropertyDescriptors()

🛈 keys()

🛈 values()


Clone this wiki locally