Anonymous user
Multiple distinct objects: Difference between revisions
→{{header|Lua}}
Line 596:
=={{header|Lua}}==
<lang Lua>-- This concept is relevant to tables in Lua
-- The following will create a table of references to table1
<lang Lua>function nRefs (t, n)▼
for i = 1,
for i = 1, 10 do refTab[n] = t end▼
-- Instead, tables should be copied using a function like this ▼
▲Instead, tables should be copied using a function like this
local new = {}
for k, v in pairs(t) do new[k] = v end
return new
Now we can create a table of independent copies of table1▼
▲ local copyTab = {}
end
▲-- Now we can create a table of independent copies of table1
local copyTab = {}
=={{header|Mathematica}}==
|