table.Merge

From GMod Wiki

Jump to: navigation, search


Function
Syntax table.Merge( Table destination table, Table source table )
Where is this used?
Description:
Merges the contents of a table into another table.
Returns: Table destination table
Part of Library: Table
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Table.Merge]Table.Merge [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionMerge a table into another. Shows how it overwrites keys.
Used onNewerShared.png
Code
 
test_table = {"this","that","and the other","delta","epsilon"} // Define the destination table.
test_table_2 = {"alpha","beta","gamma"} // Define the source table.
table.Merge(test_table,test_table_2)
print(table.concat(test_table," ")) // Prints "alpha beta gamma delta epsilon" to the console.
 
Output"this", "that", "and the other" are lost due to their key being 1, 2 and 3, the source table already has 1, 2 and 3 set to different variables. Prints the result to the console.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox