lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


--- "Tim Royal (ArtSource)" <a-tiroya@microsoft.com> wrote:
> Is there any facility that will let me make an independent copy of a
> table and all its nested tables (yes, I understand the circular
> reference problem that could occur, so I'll need to be careful).

You just write your own. Here's the basic idea (I'm sure users here have more sophisticated
version):

function deep_copy (table)
  t = {}
  for k,v in table do
    if type(v) == 'table'
      v = deep_copy(v)
    end
    t[k] = v
  end
  return t
end


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com