Garry's Mod Wiki

table.remove

any table.remove( table tbl, number index = #tbl )

Description

Removes a value from a table and shifts any other values down to fill the gap.

Arguments

1 table tbl
The table to remove the value from.
2 number index = #tbl
The index of the value to remove.

Returns

1 any
The value that was removed.

Example

Demonstrates the use of this function.

sentence = { "hello", "there", "my", "name", "is", "Player1" } print( table.remove( sentence ) ) -- Using no second arg removes the last value print( table.remove( sentence, 2 ) ) PrintTable( sentence )
Output: Player1 there 1 = hello 2 = my 3 = name 4 = is

Page Links


Special Pages


Wikis

?

Render Time: 31ms

Session 0
DB GetPage 4
Generate Html 6
SaveChanges 8
Render Body 0
Render Sidebar 11