1
0
mirror of https://github.com/AR2000AR/openComputers_codes.git synced 2025-09-04 12:45:58 +02:00
Files
2023-12-02 14:26:46 +01:00
..
2023-08-16 15:12:42 +02:00
2023-08-16 15:12:42 +02:00
2023-12-02 14:26:46 +01:00

libClass2

local class = require("libClass2")

---@class A:Object
local A = class()


--constructor 
function A:new()
  --call the parent's constructor
  local o = self.parent()
  -- this line make `o` a objet of class `A`
  o = setmetatable(o, {__index = self})
  ---@cast o A
  o.member = 1
  return o
end

function A:method()
  self.member = self.member +1
  return self.member
end

---@class B:A
local B = class(A)

local a = A()
print(a:method())

local b = B
print(b:method())