Syntax
getconstant(target: function | integer, index: number | integer): any | nilAliases
debug.getconstantArguments
| Name | Type | Description |
|---|---|---|
target | function | integer | Function, stack level, or prototype to inspect. |
index | number | integer | One-based index inside constants, protos, upvalues, or stack slots. |
Returns
| Name | Type | Description |
|---|---|---|
constant | any | nil | Constant value at the requested index, or nil when it is missing. |
Description
Reads a constant from a function, stack level, or prototype by one-based index.
Call it with 2 parameter(s): target, index. The argument table explains which values are required and which ones only refine the behavior.
It returns constant (any | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Example call with placeholder values.
local result = getconstant(1, 1)
print(result)