Will that transfer every aspect of the original item1 including all nested tables contained therein? What about any functions that might also be contained or images, canvases, whatever that may or may not also be included as part of the table?
And if you do that, and change B, then A would be changed too! Took me a while to wrap my head around that when starting out in Lua. Can cause some subtle bugs if you ever assume it'll behave otherwise.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit! Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
table1 = {
key = 'value', --string key
[2] = 123, -- number key
-- etc
}
table2 = {}
for key,value in pairs(table1) do
table2[key] = value
end
table1 = {} -- or nil, depends of what you want
another great thing in Lua is the facility to swap variables: