Yuari
Documentation
Docs/Metatables/hasmetafield

hasmetafield

Returns true when an object's raw metatable contains the field.

Syntax

hasmetafield(object: any, key: string) -> boolean

Parameters

ParameterTypeDescription
objectanyThe object value used by the call.
keystringThe key or secret used by the operation.

Returns

TypeDescription
booleanTrue when an object's raw metatable contains the field

Description

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

The call is a predicate: it inspects the current state and returns a boolean without modifying anything.

Example

print(hasmetafield(setmetatable({}, { __index = function() end }), "__index"))

Notes

  • Metatable changes are applied directly to the live object.