[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Pass vars value not reference to table.insert
- From: Jan Schütze <JanS@...>
- Date: Sat, 27 Jan 2007 13:28:48 +0100
Hello,
The following pseudo code won't add every 3 rows to the table rows,
because row is a variable so rows would contain one item, and 3 pointers
to it.
rows={}
local row = fetchRow()
while (row) do
table.insert(rows,row)
row = fetchRow()
end
Is there any way to add the 'row'-values content and not a pointer to it?
Currently I use:
rows={}
local row = fetchRow()
while (row) do
local row2={}
for key,value in pairs(row) do
row2[key]=value
end
table.insert(rows,row2)
row = fetchRow()
end
But I am sure this is easier in lua.
Kind regards,
Jan (DracoBlue)
--------------------------
http://dracoblue.net