Metatables

hasmetatable

Checks whether a target value has a metatable.

Syntax

hasmetatable(target: any): boolean

Arguments

NameTypeDescription
targetanyTarget function, table, stack level, or object being inspected or changed.

Returns

NameTypeDescription
hasMetatablebooleanTrue when the target has a metatable.

Description

Checks whether a target value has a metatable.

Call it with 1 parameter(s): target. The argument table explains which values are required and which ones only refine the behavior.

It returns hasMetatable (boolean). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = hasmetatable(nil)
print(result)