9951 explained code solutions for 126 technologies


luaHow to merge tables


This approach will overwrite all items from the first table with corresponding values from the second one (and append all values from second table which are absent in first):

for k,v in pairs(tbl2) do
  tbl1[k] = v
endctrl + c
for k,v in pairs(tbl2)

iterate through all elements of second table

tbl2

second table to add to first one

tbl1

first table to join with second

tbl1[k] = v

set given v value at k position of tbl1 table