Difference between revisions of "Setmetatable"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[(global)]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/(global)|(global)]]<br/>
 
  
=== <translate>Description</translate> ===
+
=== Description ===
<translate>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.
+
Sets the ''metatable'' for the given table.
 
 
This function returns table.</translate>
 
 
<source lang="lua">
 
<source lang="lua">
 
(table) = setmetatable(table,metatable)
 
(table) = setmetatable(table,metatable)
 
</source>
 
</source>
  
=== <translate>Parameters</translate> ===
+
You cannot change the ''metatable'' of other types from Lua, only from C.
'''table''': (table) <translate>table to set metatable to</translate> <br/>
+
 
'''metatable''': (varies) <translate>value to use as metatable</translate> <br/>
+
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 a table.
 +
 
 +
=== Parameters ===
 +
'''table''': (table) table to set metatable to<br/>
 +
'''metatable''': (varies) value to use as metatable<br/>
  
=== <translate>Return values</translate> ===
+
=== Return values ===
'''<translate>Returns</translate>''' (table) <translate>provided table</translate><br/>
+
'''Returns''' (table) provided table<br/>
  
 
{{(global)}}
 
{{(global)}}

Revision as of 22:28, 13 May 2022

Available since: Gideros 2011.6
Class: (global)

Description

Sets the metatable for the given table.

(table) = setmetatable(table,metatable)
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 a table.

Parameters

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

Return values

Returns (table) provided table