Difference between revisions of "Setmetatable"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === Sets the `metatable` for the given table. (You cannot change the `metatable` of other types from Lua,...") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(13 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 === | ||
− | Sets the | + | Sets the ''metatable'' for the given table. |
+ | <syntaxhighlight lang="lua"> | ||
+ | (table) = setmetatable(table,metatable) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 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<br/> | |
− | + | '''metatable''': (varies) value to use as metatable<br/> | |
− | + | ||
− | '''table | + | === Return values === |
− | '''metatable | ||
'''Returns''' (table) provided table<br/> | '''Returns''' (table) provided table<br/> | ||
+ | |||
+ | {{(global)}} |
Latest revision as of 14:32, 13 July 2023
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