Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

hollywoodlibs:tables:testmerge [2016/10/21 00:18] (versione attuale)
admin creata
Linea 1: Linea 1:
 +====== 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()**.
 +
 +<​code>​
 +  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)
 +</​code>​
 +
 +The example does not need further explanations as you can see.
hollywoodlibs/tables/testmerge.txt ยท Ultima modifica: 2016/10/21 00:18 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0