Syntax
getrawmetatable(target: any): table | nilAliases
debug.getmetatableArguments
| Name | Type | Description |
|---|---|---|
target | any | Value whose metatable is returned. |
Returns
| Name | Type | Description |
|---|---|---|
metatable | table | nil | Target metatable when present; otherwise nil. |
Description
Returns the metatable currently attached to a target value, or nil when none is present. The function returns exactly one value and does not change the target. debug.getmethods is an alias for getrawmethods.
Call it with 1 parameter(s): target. The argument table explains which values are required and which ones only refine the behavior.
It returns metatable (table | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Return the metatable currently attached to a value.
local target = {}
local meta = {
label = "Real",
}
setrawmetatable(target, meta)
print(getrawmetatable(target) == meta)
print(debug.getmetatable(target) == meta)