table.remove

From Garry's Mod
Jump to: navigation, search
 table.remove( )

Contents

Description

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

Arguments

table tbl

The table to remove the value from.

Arguments

number index=#tbl

The index of the value to remove.

Returns

any

The value that was removed.

Examples

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
Personal tools
Navigation