Garry's Mod Wiki


  table table.Merge( table destination, table source, boolean forceOverride = false )


Recursively merges the key-value pairs of the source table with the key-value pairs in the destination table.

See table.Inherit, which doesn't override existing values.

See also table.Add, which simply adds values of one table to another.

This function can cause a stack overflow under certain circumstances.


1 table destination
The table you want the source table to merge with.
2 table source
The table you want to merge with the destination table.
3 boolean forceOverride = false
If true, does not recursively merge sub-tables, and simply replaces them.


1 table
Destination table


"Merges" the content of the second table with the first one, overwriting any matching key/value pairs in the destination with the source's version and prints the resulting merge.

local destination = {[1] = "A", [2] = "Golden", [3] = "Apple"} local source = {[1] = "Two", [2] = "Orange"} table.Merge( destination, source ) PrintTable( destination )
1 = Two 2 = Orange 3 = Apple