Re: Moving key & values from one table to another
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Moving key & values from one table to another
- From: Hercinger Viktor <hercinger.viktor@...>
- Date: 2006年3月02日 02:17:38 +0100
Well, I got that in the meantime, thanks... :-)
Ashwin Hirschi wrote:
Are there any tricks to insert all the keys and values of one table into
another?
function dup(tab)
local res = {}
if type(tab) ~= "table" then return tab end
for k, v in tab do res[dup(k)] = dup(v) end
return res
end
And it's kind of safe too :)
Eh... kind-of-safe as in "only returns with a stack overflow" from:
a = {}
a.b = a
dup(a)
you mean? [;-)]
Ashwin.
--
Hercinger Viktor
0x2b || !0x2b