deep_copy
deep_copy(table) returns a deep, recursive copy of a table. Every nested table is cloned, ensuring total isolation from the original. Safely handles circular references.
Signature
Section titled “Signature”deep_copy(table)
syncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
table |
table | The table to copy |
Returns
Section titled “Returns”| Value | Type | Description |
|---|---|---|
| deep | table | A deep copy (every nested table is cloned) |
Example
Section titled “Example”local original = { a = 1, b = { c = 2 } }local deep = deep_copy(original)deep.b.c = 99 -- original.b.c remains 2See Also
Section titled “See Also”- copy - Shallow copy (first level only)