diff options
| author | ruki <[email protected]> | 2024-01-10 00:52:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-10 00:52:47 +0800 |
| commit | 41b348d3cc68845e121aa489c4b20fb06026cfe8 (patch) | |
| tree | cb88d7d4cd12a282a41ff97c8faed3dbc8a32d15 /xmake/core/base/table.lua | |
| parent | 95474ba466926b8a06bc0a610305d0ad3373c1d9 (diff) | |
fix test #4582
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 |
