Difference between revisions of "Table.insert"
From GiderosMobile
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
| − | + | '''Available since:''' Gideros 2011.6<br/> | |
| − | ''' | + | '''Class:''' [[table]]<br/> |
| − | ''' | + | |
| − | === | + | === Description === |
| − | + | Inserts an element value at position pos in table, shifting up other elements to open space if necessary. | |
<source lang="lua"> | <source lang="lua"> | ||
| − | + | table.insert(table,pos,value) | |
</source> | </source> | ||
| − | === | + | |
| − | '''table''': (table) | + | 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. |
| − | '''pos''': (number) | + | |
| − | '''value''': (any) | + | === Parameters === |
| + | '''table''': (table) table where to insert new element<br/> | ||
| + | '''pos''': (number) index where to insert new element '''optional'''<br/> | ||
| + | '''value''': (any) value to insert in table '''optional'''<br/> | ||
{{Table}} | {{Table}} | ||
Revision as of 01:44, 19 March 2021
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 optional