Add

From Pico-8 Wiki
Revision as of 22:54, 6 June 2016 by imported>Dddaaannn (New reference article: add)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
add( tbl, v )
Adds a element to the end of a sequence in a table.
tbl
The table.

v
The value to add.

The add() function appends an element to the end of a sequence in a table.

Specifically, add() looks for an element at index 1, increments the index until it finds no element assigned (nil), then assigns the new value to that unused index.

Examples

t = {1, 3, 5}
add(t, 7)  -- t = {1, 3, 5, 7}
add(t, 9)  -- t = {1, 3, 5, 7, 9}

See also