lua_oop/main.lua

17 lines
336 B
Lua

oop = require("oop/oop")
local function MyClass(cls)
cls.setattr(cls, "name")
function cls.__init(this, name)
this.name = name
end
function cls.test(this, name)
print("hi " .. this.name .. " from " .. name)
end
end
local obj = oop.new(MyClass, "Carl")
obj.test("tom") -- Output: hi Carl from tom