Skip to content
Debug libraryOverview

debug.getconstants

Represents inspection of function constants.

Aliasesgetconstants

Details#

Returns the constant pool of a Luau function or stack level with one-based indices. Function, table and nil entries appear as holes. Compiler optimization changes pool contents and order; use pairs to inspect available entries.

Examples#

Example

Luau
local f = assert(loadstring("return 'docs constant'"))
for index, value in pairs(debug.getconstants(f)) do
    print(index, value)
end