Yuari
Documentation
Docs/Metatables/setrawmetatable

setrawmetatable

Replaces the raw metatable.

Syntax

setrawmetatable(object: any, metatable: table) -> nil

Parameters

ParameterTypeDescription
objectanyThe object value used by the call.
metatabletableThe metatable value used by the call.

Returns

TypeDescription
nilThis function does not return a value.

Description

setrawmetatable is part of the Metatables library. Metatable helpers operate below normal Lua protection: they read raw metatables, replace metamethods and inspect namecalls.

The change is applied directly to the live target, so later reads observe the updated value.

Example

local object = {}
setrawmetatable(object, { __index = function() return 1 end })
print(object.anything)

Notes

  • Metatable changes are applied directly to the live object.