Difference between revisions of "Setmetatable"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Available since:''' Gideros 2011.6<br/>
+
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
=== Description ===
+
=== <translate>Description</translate> ===
 
<translate>Sets the [[Special:MyLanguage/metatable|metatable]] for the given table. (You cannot change the [[Special:MyLanguage/metatable|metatable]] of other types from Lua, only from C.) If [[Special:MyLanguage/metatable|metatable]] is nil, removes the [[Special:MyLanguage/metatable|metatable]] of the given table. If the original [[Special:MyLanguage/metatable|metatable]] has a "__metatable" field, raises an error.  
 
<translate>Sets the [[Special:MyLanguage/metatable|metatable]] for the given table. (You cannot change the [[Special:MyLanguage/metatable|metatable]] of other types from Lua, only from C.) If [[Special:MyLanguage/metatable|metatable]] is nil, removes the [[Special:MyLanguage/metatable|metatable]] of the given table. If the original [[Special:MyLanguage/metatable|metatable]] has a "__metatable" field, raises an error.  
  
Line 9: Line 9:
 
(table) = setmetatable(table,metatable)
 
(table) = setmetatable(table,metatable)
 
</source>
 
</source>
=== Parameters ===
+
=== <translate>Parameters</translate> ===
 
'''table''': (table) <translate>table to set metatable to</translate> <br/>
 
'''table''': (table) <translate>table to set metatable to</translate> <br/>
 
'''metatable''': (varies) <translate>value to use as metatable</translate> <br/>
 
'''metatable''': (varies) <translate>value to use as metatable</translate> <br/>
=== Return values ===
+
=== <translate>Return values</translate> ===
'''Returns''' (table) <translate>provided table</translate><br/>
+
'''<translate>Returns</translate>''' (table) <translate>provided table</translate><br/>

Revision as of 08:29, 24 August 2018

Available since: Gideros 2011.6

Description

Sets the metatable for the given table. (You cannot change the metatable of other types from Lua, only from C.) If metatable is nil, removes the metatable of the given table. If the original metatable has a "__metatable" field, raises an error.


This function returns table.
(table) = setmetatable(table,metatable)

Parameters

table: (table) table to set metatable to
metatable: (varies) value to use as metatable

Return values

Returns (table) provided table