diff options
Diffstat (limited to 'xmake/core/base/table.lua')
| -rw-r--r-- | xmake/core/base/table.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index f954596b8..fbef78a25 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -154,12 +154,16 @@ function table.append(array, ...) end -- clone table -function table.clone(self) +-- +-- @param depth e.g. shallow: 1, deep: -1 +-- +function table.clone(self, depth) + depth = depth or 1 local result = self - if type(self) == "table" then + if type(self) == "table" and depth > 0 then result = {} for k, v in pairs(self) do - result[k] = v + result[k] = table.clone(v, depth - 1) end end return result |
