Syntax
hasmetafield(target: any, field: string): booleanArguments
| Name | Type | Description |
|---|---|---|
target | any | Target function, table, stack level, or object being inspected or changed. |
field | string | Metatable field name to inspect. |
Returns
| Name | Type | Description |
|---|---|---|
hasField | boolean | True when the metatable contains the requested field. |
Description
Checks whether a metatable contains a field.
Call it with 2 parameter(s): target, field. The argument table explains which values are required and which ones only refine the behavior.
It returns hasField (boolean). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Example call with placeholder values.
local result = hasmetafield(nil, "example")
print(result)