hasmetafield Synchronous
Check whether an object’s raw metatable defines a non-nil field. Use it before taking a path that depends on a particular metamethod.
Luau
hasmetafield(value: any, field: string) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
value | any | Value to inspect. |
field | string | Field name to test. |
Returns
booleantrue if the raw metatable field is non-nil.
Example
Luau
local object = setmetatable({}, { __index = function() end })
print(hasmetafield(object, "__index")) -- true