WoW:API rawset: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
m (Move page script moved page API rawset to API rawset without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LUA}}
{{luaapi}}
 
Assigns a value to a key in the table, without invoking [[metamethod]]s.
== Usage ==
 
This function does the same as table[index] = value, without invoking any [[metamethod]]s.
 
  table = rawset (table, index, value)
  table = rawset (table, index, value)


== Parameters ==
== Arguments ==
=== Arguments ===
;table : table - any valid table.
:;table : table - any valid table.
;index : non-nil - any valid table index.
:;index : numeric - any valid table index.
;value : any - any value.
:;value : any - any value.


==Returns==
==Returns==
:;table : table - the table you passed as the first parameter.
;table : table - the table you passed as the first parameter.


== Example ==
== Example ==
Line 21: Line 16:


==Details==
==Details==
Sets the real value of <i>table</i>[<i>index</i>] to <i>value</i>, without invoking any metamethod. <i>table</i> must be a table, <i>index</i> any value different from nil, and <i>value</i> any Lua value.
Sets the real value of ''table''[''index''] to ''value'', without invoking any metamethod. ''table'' must be a table, ''index'' any value different from nil, and ''value'' any Lua value.


==Notes==
==Notes==

Latest revision as of 04:47, 15 August 2023

WoW Lua

Assigns a value to a key in the table, without invoking metamethods.

table = rawset (table, index, value)

Arguments[edit]

table
table - any valid table.
index
non-nil - any valid table index.
value
any - any value.

Returns[edit]

table
table - the table you passed as the first parameter.

Example[edit]

mytable = { }
rawset(mytable, "version", 1.0)

Details[edit]

Sets the real value of table[index] to value, without invoking any metamethod. table must be a table, index any value different from nil, and value any Lua value.

Notes[edit]

Metamethods can be used to change the way LUA works with certain variables. For example you could change what LUA does if you set a tables index to a new value. By using rawset you can set an index without invoking these methods, which is primarily usefull in the metamethod that actually sets the tables index to value, otherwise this metamethod would invoke itself over and over again.

Template:AlsoSee