-- Returns a new table, recursively copied from the one given.
--
-- @param   table   table to be copied
-- @return  table
local function tbl_copy(orig)
    local orig_type = type(orig)
    local copy
    if orig_type == "table" then
        copy = {}
        for orig_key, orig_value in next, orig, nil do
            copy[tbl_copy(orig_key)] = tbl_copy(orig_value)
        end
    else -- number, string, boolean, etc
        copy = orig
    end
    return copy
end

引自resty的http,做个记录,方便后期使用

相关文章:

  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2021-11-17
  • 2021-07-31
  • 2021-08-11
  • 2021-12-15
猜你喜欢
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2021-12-31
  • 2021-06-20
  • 2021-09-09
  • 2021-07-10
相关资源
相似解决方案