Class: minor changes

This commit is contained in:
Van
2026-07-08 20:24:14 +03:00
parent b40b8c97c0
commit a504223240
2 changed files with 4 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
local setMetaTable, tableCopy = setmetatable, table.copy_with_metatables
local tableMerge, setmetatable, tableCopy = table.merge, setmetatable, table.copy_with_metatables
---@class Class
Class = {}
@@ -7,7 +7,7 @@ Class = {}
---@param parent table
---@param child table?
function Class.extend(parent, child)
return setMetaTable(child or {}, { __index = tableCopy(parent) })
return tableMerge(child or {}, tableCopy(parent))
end
---Intended for class constructors.
@@ -25,7 +25,7 @@ function Class.getInstance(self, params, metatable)
metatable.__index = tableCopy(self)
local instance = setMetaTable(params, metatable)
local instance = setmetatable(params, metatable)
return instance
end