Getmetatable: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 5: Line 5:
=== Description ===
=== Description ===
Returns the metatable of the given object.
Returns the metatable of the given object.
<source lang="lua">
<syntaxhighlight lang="lua">
(table) = getmetatable(object)
(table) = getmetatable(object)
</source>
</syntaxhighlight>


*if ''object'' does not have a metatable, returns nil.
*if ''object'' does not have a metatable, returns nil.
Line 18: Line 18:
=== Return values ===
=== Return values ===
'''Returns''' (table) metatable<br/>
'''Returns''' (table) metatable<br/>
=== See also ===
'''https://luau.org/library#global-functions'''<br/>


{{(global)}}
{{(global)}}

Latest revision as of 10:20, 21 July 2025

Available since: Gideros 2011.6
Class: (global)

Description

Returns the metatable of the given object.

(table) = getmetatable(object)
  • if object does not have a metatable, returns nil.
  • if the object metatable has a "__metatable" field, returns the associated value.
  • otherwise, returns the metatable of the given object.

Parameters

object: (object) object from which to get metatable

Return values

Returns (table) metatable

See also

https://luau.org/library#global-functions