hasmetafield
Checks whether a value's raw metatable defines a field.
Answers the same question as getmetafield returning a non-nil value, without handing the field itself to the caller.
hasmetafield(value: any, field: string): booleanParameters
| Parameter | Type | Description |
|---|---|---|
value | any | Value whose metatable is read. |
field | string | Field name. |
Example
local subject = setmetatable({}, { __index = {} })
print(hasmetafield(subject, "__index"), hasmetafield(subject, "__call"))Example output
true false