Class: minor changes
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user