Add
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.
The add() function returns the object being added. (You can ignore this return value.)
Examples
t = {1, 3, 5}
add(t, 7) -- t = {1, 3, 5, 7}
add(t, 9) -- t = {1, 3, 5, 7, 9}