루아는 하나의 자료구조만 가지고 모든것을 구현할 수 있다. 그리고 루아의 테이블은 다른 언어와 다르게 인덱스가 1부터 시작한다. 또한 테이블안에 다른 테이블이 들어갈 수 있고 키와 값을 넣어 딕셔너리 같이 사용할 수도 있다.

obj = {
  x = 64,
  y = 64,
}
obj.color = "white"
obj["x"] = 16 --> obj.x = 16
 
arr = {1,2,3,4,5}
arr[1] --> 1

시퀀스는 이터러블하다

a = {1, 2, 3, 4, 5}
for i = 1, #a do
  print(a[i])
end
a = {1, nil, nil, nil, 5}
#a --> 5
b = {1, 2, 3, nil, nil}
#b --> 3
a = {x = 64, y = 16, color = 7}
for key, value in pairs(a) do
  print(key, value)
end
 
for index, value in ipairs(a) do
  print(index, value)
end

api

table.concat()
table.foreach()
table.foreachi()
table.getn()
table.sort()
table.insert()
table.remove()
table.setn()