Let's say I have an Array {"Hi", "Bye", "Welcome"} and I want to add an "Potato" on the [4] how can I do that? Thanks!
Using table.insert
.
Pretty easy actually;
1 | local aa = { 'a' , 1 } |
2 |
3 | table.insert(aa, 3 , 'b' ) --1st argument is the table, 2nd one is the position, 3rd is the value(string, bool, int). |
4 |
5 | --To make it so it's at the last position. |
6 | table.insert(aa,#aa+ 1 , 'last' ) |
EDIT* Made a mistake, 2nd argument is the position, the 3rd is the value.