hasmetafield
Returns true when an object's raw metatable contains the field.
Syntax
hasmetafield(object: any, key: string) -> boolean
Parameters
| Parameter | Type | Description |
|---|---|---|
object | any | The object value used by the call. |
key | string | The key or secret used by the operation. |
Returns
| Type | Description |
|---|---|
boolean | True 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.