Difference between revisions of "Table.insert"
From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")  | 
				|||
| (One intermediate revision by the same user not shown) | |||
| Line 5: | Line 5: | ||
=== Description ===  | === Description ===  | ||
Inserts an element value at position pos in table, shifting up other elements to open space if necessary.  | Inserts an element value at position pos in table, shifting up other elements to open space if necessary.  | ||
| − | <  | + | <syntaxhighlight lang="lua">  | 
table.insert(table,pos,value)  | table.insert(table,pos,value)  | ||
| − | </  | + | </syntaxhighlight>  | 
The default value for pos is n+1, where n is the length of the table, so that a call table.insert(t,x) inserts x at the end of table t.  | The default value for pos is n+1, where n is the length of the table, so that a call table.insert(t,x) inserts x at the end of table t.  | ||
| Line 21: | Line 21: | ||
=== Description ===  | === Description ===  | ||
Appends the provided value to the end of the array.  | Appends the provided value to the end of the array.  | ||
| − | <  | + | <syntaxhighlight lang="lua">  | 
table.insert(table,value)  | table.insert(table,value)  | ||
| − | </  | + | </syntaxhighlight>  | 
=== Parameters ===  | === Parameters ===  | ||
Latest revision as of 14:33, 13 July 2023
Available since: Gideros 2011.6
Class: table
Description
Inserts an element value at position pos in table, shifting up other elements to open space if necessary.
table.insert(table,pos,value)
The default value for pos is n+1, where n is the length of the table, so that a call table.insert(t,x) inserts x at the end of table t.
Parameters
table: (table) table where to insert new element
pos: (number) index where to insert new element optional
value: (any) value to insert in table
Description
Appends the provided value to the end of the array.
table.insert(table,value)
Parameters
table: (table) table where to insert new element
value: (any) value to insert at end of table