Rawset: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
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 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.
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.
 
This function returns table.</translate>
<source lang="lua">
<source lang="lua">
(table) = rawset(table,key,value)
(table) = rawset(table,key,value)
</source>
</source>


=== <translate>Parameters</translate> ===
=== Parameters ===
'''table''': (table) <translate>table to set the value to</translate> <br/>
'''table''': (table) table to set the value to <br/>
'''key''': (any) <translate>key of the table to set the value to</translate> <br/>
'''key''': (any) key of the table to set the value to <br/>
'''value''': (any) <translate>value to store in the table</translate> <br/>
'''value''': (any) value to store in the table <br/>
 
=== Return values ===
'''Returns''' (table) provided table<br/>


=== <translate>Return values</translate> ===
=== Example ===
'''<translate>Returns</translate>''' (table) <translate>provided table</translate><br/>
'''Generate variable names'''
<source lang="lua">
for i = 1, 10 do
rawset(_G, "item"..i, "I am "..i)
end
print(item1) -- I am 1
print(item2) -- I am 2
print(item3) -- I am 3
-- ...
</source>


{{(global)}}
{{(global)}}

Revision as of 20:28, 13 May 2022

Available since: Gideros 2011.6
Class: (global)

Description

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.

(table) = rawset(table,key,value)

Parameters

table: (table) table to set the value to
key: (any) key of the table to set the value to
value: (any) value to store in the table

Return values

Returns (table) provided table

Example

Generate variable names

for i = 1, 10 do
	rawset(_G, "item"..i, "I am "..i)
end
print(item1) -- I am 1
print(item2) -- I am 2
print(item3) -- I am 3
-- ...