Debug

getconstants

Returns all constants embedded in a function, stack level, or prototype.

Syntax

getconstants(target: function | integer): table
Aliases debug.getconstants

Arguments

NameTypeDescription
targetfunction | integerFunction, stack level, or prototype to inspect.

Returns

NameTypeDescription
constantstableArray table of constants embedded in the function.

Description

Returns all constants embedded in a function, stack level, or prototype.

Call it with 1 parameter(s): target. The argument table explains which values are required and which ones only refine the behavior.

It returns constants (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getconstants(1)
print(result)