Skip to content
Debug libraryOverview

debug.getconstant

Represents inspection of a function constant.

Aliasesgetconstant

Details#

Reads a constant at a one-based pool index. Unsupported constant types yield nil; an empty pool or out-of-range index raises an error. Determine the index from getconstants rather than assuming source order.

Examples#

Example

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