Garry's Mod Wiki

table.Merge

table table.Merge( table destination, table source )

Description

Merges the contents of the second table with the content in the first one. The destination table will be modified.

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

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

This function will cause a stack overflow under certain circumstances.

Arguments

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

Returns

1 table
Destination table

Example

"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 )
Output: 1 = Two 2 = Orange 3 = Apple

Page Links


Special Pages


Wikis

?

Render Time: 80ms

DB GetPage 51
Generate Html 5
SaveChanges (1) 10
Render Body 0
Render Sidebar 12