Metatables

setrawmetatable

Sets the raw metatable for a target value and returns the target.

Syntax

setrawmetatable(target: any, value: any): any
Aliases debug.setmetatable

Arguments

NameTypeDescription
targetanyTarget function, table, stack level, or object being inspected or changed.
valueanyNew value to write.

Returns

NameTypeDescription
targetanyThe target value after its metatable is changed.

Description

Sets the raw metatable for a target value and returns the target.

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

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

Example

Example call with placeholder values.

local result = setrawmetatable(nil, nil)
print(result)