> ## Documentation Index
> Fetch the complete documentation index at: https://gluals.arnux.net/llms.txt
> Use this file to discover all available pages before exploring further.

# @copy_result

> Mark a function that returns a copy of the table it is given.

> [!NOTE]
>
> This annotation is intended for complex cases and is primarily designed to be used by the built-in annotations.

## Overview

`copy_result` marks a function such as `table.Copy` that returns a new table starting with the contents of its first argument.

The copy keeps the original's fields and methods. Fields you add to the copy stay on the copy and never show on the original.

***

## Syntax

```lua theme={null}
---@return T
---@[copy_result]
```

Put it after the `@return` line.

***

## Example

```lua theme={null}
---@generic T
---@param originalTable T
---@return T
---@[copy_result]
function table.Copy(originalTable) end
```

```lua theme={null}
local defaults = { Speed = 10 }
local settings = table.Copy(defaults)
settings.Extra = true

print(settings.Speed) -- number
print(defaults.Extra) -- undefined field
```

***

## See also

* [`@return_alias`](https://gluals.arnux.net/annotations/return-alias): a function that returns its argument unchanged


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.