copy
copy(table) returns a shallow copy of a table. Only the first level of keys and values are copied. Nested tables are still shared by reference.
Signature
Section titled “Signature”copy(table)
syncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
table |
table | The table to copy |
Returns
Section titled “Returns”| Value | Type | Description |
|---|---|---|
| shallow | table | A shallow copy (only first level is copied) |
Example
Section titled “Example”local original = { a = 1, b = { c = 2 } }local shallow = copy(original)shallow.a = 99 -- original.a is still 1shallow.b.c = 99 -- original.b.c IS now 99See Also
Section titled “See Also”- deep_copy - Recursive deep copy