table.insert lua code example

Example 1: lua add table to value

table.insert(table, position:num, value:any)

Example 2: lua insert table into table

table.insert(tabletoaddto, pos:num, tabletoinsert)

Example 3: lua add to table

foo = {}
table.insert(foo, "bar")
table.insert(foo, "baz")

Example 4: lua table insert

t = { "the", "quick", "brown", "fox" }
table.insert (t, 2, "very") -- new element 2
table.insert (t, "jumped")  -- add to end of table
table.foreachi (t, print)

 -->

1 the
2 very
3 quick
4 brown
5 fox
6 jumped

Example 5: lua add to table

table[#table + 1] = val

Example 6: lua how to add something to a table

foo = {}
table.insert(foo, "bar")
table.insert(foo, "baz")

Tags:

Sql Example