lua push to aray
- Create an empty array by using the following code:
myArray = {}
- Add elements to the array using the following syntax:
myArray[1] = "apple"
myArray[2] = "banana"
myArray[3] = "orange"
- Access the elements of the array using the following code:
print(myArray[1]) -- Outputs: apple
print(myArray[2]) -- Outputs: banana
print(myArray[3]) -- Outputs: orange
- Iterate through the elements of the array using a loop, like this:
for i = 1, #myArray do
print(myArray[i])
end