add(table,value,[index])

Overview

add adds a value to the end of the table or at [index].

Without an index, it is equivalent to:

tbl[#tbl + 1] = val

Arguments

table: table

The table you would like to add value to.

value: any

The value to add into the table table

[index]: integer

The index of where to place the item in the table table, defaults to the end of the table.

Examples

Sourced from the Picotron Manual

foo={}-- create empty table
add(foo, 11)
add(foo, 22)
?foo[2] -- 22