Garry's Mod Wiki

Garry's Mod Wiki

  number table.insert( table tbl, number position, any value )


Inserts a value into a table at the end of the table or at the given position.

This function does not call the __newindex metamethod.


1 table tbl
The table to insert the variable into.
2 number position
The position in the table to insert the variable. If the third argument is nil this argument becomes the value to insert at the end of given table.
3 any value
The variable to insert into the table.


1 number
The index the object was placed at.


Demonstrates the use of this function.

sentence = { "hello", "there", "my", "name", "is", "drakehawke" } table.insert( sentence, "lol" ) table.insert( sentence, 6, "not" ) PrintTable( sentence )
1 = hello 2 = there 3 = my 4 = name 5 = is 6 = not 7 = drakehawke 8 = lol

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...