Search code examples
mergelualua-table

How to merge two tables overwriting the elements which are in both?


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 offer this. Where can I get such a function?


Solution

  • for k,v in pairs(second_table) do first_table[k] = v end