Home Contents | # table.combine | Table | Core4 Lua Commands

## SYNOPSIS

dst = table.combine(src[, src[, ...]])

## DESCRIPTION

Combines the contents of all src tables into one table.
The operation proceeds through the arguments from left to right, later keys overwriting earlier keys of the same value.
Nested tables are combined recursively with deep copy. The resulting table will have no references to any source tables.

table.duplicate() is an alias for table.combine() since SDK 1.6.16. It makes code more readable when this function is used to deep-copy a single table.

## EXAMPLE

> > > >
a = { x = 5 } b = { y = 7 } c = table.combine(a, b) for k,v in pairs(c) do print(k,v) end
y 7 x 5

## NOTES

If you want to do dst = table.combine(dst, src), you might want to prefer table.merge which does this more efficiently.

To get a deep copy of a table, simply use table.combine() with a single argument.

## SEE ALSO

table.merge