Home  Contents

table.merge

Table Core4 Lua Commands

SYNOPSIS

table.merge(dst[, src[, ...]])

DESCRIPTION

Merges the contents of the table src into the table dst.
Keys from src that are already in dst are overwritten.
Other keys in dst are unchanged.
Several src arguments may be given, which are merged into dst in the given order.
Nested tables are merged recursively-by-reference: if a nested table is encountered and there is not already a table at the target key, a simple lua assignment is done, which does not copy.

EXAMPLE

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

SEE ALSO