Yuari
Documentation
Docs/Metatables/hasmetatable

hasmetatable

Returns true when the object has a metatable.

Syntax

hasmetatable(object: any) -> boolean

Parameters

ParameterTypeDescription
objectanyThe object value used by the call.

Returns

TypeDescription
booleanTrue when the object has a metatable

Description

hasmetatable is part of the Metatables library. Metatable helpers operate below normal Lua protection: they read raw metatables, replace metamethods and inspect namecalls.

The call is a predicate: it inspects the current state and returns a boolean without modifying anything.

Example

print(hasmetatable(setmetatable({}, {}))) -- true

Notes

  • Metatable changes are applied directly to the live object.