Difference between revisions of "Getmetatable"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a "__metata...")
 
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 +
'''Class:''' [[(global)]]<br/>
 +
 
=== Description ===
 
=== Description ===
If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a "__metatable" field, returns the associated value. Otherwise, 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>
'''object:''' (object) Object from which to get metatable ''''''<br/>
+
 
 +
*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<br/>
 +
 
 +
=== Return values ===
 
'''Returns''' (table) metatable<br/>
 
'''Returns''' (table) metatable<br/>
 +
 +
=== See also ===
 +
'''https://luau.org/library#global-functions'''<br/>
 +
 +
{{(global)}}

Latest revision as of 12: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