Lua - merge tables?

前端 未结 8 1491
忘掉有多难
忘掉有多难 2020-11-28 06:45

I need to merge two tables, with the contents of the second overwriting contents in the first if a given item is in both. I looked but the standard libraries don\'t seem to

8条回答
  •  一整个雨季
    2020-11-28 06:58

    For numeric-index table merging:

    for k,v in pairs(secondTable) do table.insert(firstTable, v) end
    

提交回复
热议问题