> ## 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.

# @param

> Document function parameter types and descriptions.

## Overview

`@param` declares the type and optional description of each function parameter. Place one `@param` per parameter, directly above the function definition.

***

## Syntax

```lua theme={null}
---@param paramName type [description]
---@param paramName? type [description]
```

***

## Basic usage

```lua theme={null}
---@param name string The player's display name
---@param age number The player's age
function createUser(name, age) end
```

***

## Optional parameters

Add `?` after the name to mark the parameter as `nil` in some calls:

```lua theme={null}
---@param damage number Base damage to deal
---@param attacker? Entity The attacking entity (may be nil)
function TakeDamage(victim, damage, attacker) end
```

***

## Union types

```lua theme={null}
---@param id string | number User ID (string or numeric)
function GetUser(id) end
```

***

## Variadic parameters

Use `...` as the parameter name for variadic arguments:

```lua theme={null}
---@param format string Format string
---@param ... any Additional arguments
function printf(format, ...) end
```

***

## Function-type parameters

```lua theme={null}
---@param callback fun(ply: Player, data: table): boolean
function RegisterCallback(callback) end
```

***

## Table-type parameters

```lua theme={null}
---@param options { maxHealth: number, armor?: number, speed: number }
function SpawnWithOptions(options) end
```

***

## Generic parameters

```lua theme={null}
---@generic T
---@param items T[]
---@param predicate fun(item: T): boolean
---@return T[]
function filter(items, predicate) end
```

***

## String-template generic parameters

Use backticks when the parameter is a class-name string:

```lua theme={null}
---@generic T : Entity
---@param class `T`
---@return T
function ents.Create(class) end
```

For functions accepting either a class object or class-name string:

```lua theme={null}
---@generic T
---@param name `T`|T
function useClass(name) end
```

Rule:

* `T` treats `"some_text"` as `string`
* `` `T` `` treats `"some_text"` as a class/type name

***

## `self` parameter

GLuaLS types `self` as the owning class for methods. Annotate only when you want to be explicit:

```lua theme={null}
---@param self Player
---@param amount number
function Player:GiveMoney(amount) end
```

***

## Interplay with @fileparam

GLuaLS applies file-level defaults from `@fileparam`, then workspace defaults from `gmod.fileParamDefaults`. Explicit `@param` takes highest priority.
