How to merge tables
Sometimes it's useful to have a function able to merge two tables, this function is TB.Merge(). This function recursively add all missing items on the source table to the destination table, optionally it can overwrite existing items.
Here is the example provided with the library ecapsulated in the function TB.TEST_Merge().
Local table1 = { name = "Fabio", surname = "Falcucci", age = 44 } Local table2 = { hobby = "Programming", nick = "Allanon", name = "What's up?" } NPrint("TABLE 1") ForEach(table1, NPrint) NPrint("\nTABLE 2") ForEach(table2, NPrint) Local result = TB.Merge(table1, table2, True) NPrint("\nTABLE 1") ForEach(table1, NPrint) NPrint("\nENTER TO QUIT") InKeyStr(#ALL)
The example does not need further explanations as you can see.