Revision Difference
table.Copy#568457
<function name="Copy" parent="table" type="libraryfunc">
<description>
Creates a deep copy and returns that copy. Preserves metatables using <page>debug.getmetatable</page>.
<warning>This function is very slow! If you know the table structure, it is better to write your own copying mechanism.</warning>
<warning>This function does NOT copy userdata, such as <page>Vector</page>s and <page>Angle</page>s!</warning>
</description>
<realm>Shared and Menu</realm>
<file line="22-L47">lua/includes/extensions/table.lua</file>
<args>
<arg name="originalTable" type="table">The table to be copied.</arg>
<arg name="lookupTable" type="table" default="{}">Internal table used to track already copied tables to handle circular references.</arg>
<arg name="lookupTable" type="table" default="{}"><internal notag="true"></internal>Internal table used to track already copied tables to handle circular references.</arg>
</args>
<rets>
<ret name="" type="table">A deep copy of the original table, or nil if the input table was nil.</ret>
</rets>
</function>
<example>
<description>Creates a deep copy of table Fruit</description>
<code>
local Fruit = {"Orange", "Apple", "Banana"}
local FruitCopy = table.Copy(Fruit)
PrintTable(FruitCopy)
</code>
<output>
```
1 Orange
2 Apple
3 Banana
```
</output>
</example>
Garry's Mod
Rust
Steamworks
Wiki Help