Syntax
getmetafield(target: any, field: string): any | nilArguments
| 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 |
|---|---|---|
fieldValue | any | nil | Metatable field value, or nil when absent. |
Description
Reads a field from a target metatable without changing readonly state.
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 fieldValue (any | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Example call with placeholder values.
local result = getmetafield(nil, "example")
print(result)