Lua 数组
print("===============数组===============")
arr = {1,2,nil,3,"123",true,nil,4}
print("===============数组的遍历===============")
for i = 1, #arr do
print(arr[i])
end
print("===============二维数组===============")
arrDouble = {{1,2,3},{4,5,6}}
for i = 1, #arrDouble do
local tmp = arrDouble[i]
for j = 1, #tmp do
print(tmp[j])
end
end
print("===============二维数组的遍历===============")
for i = 1, #arrDouble do
local tmp = arrDouble[i]
for j = 1, #tmp do
print(tmp[j])
end
end
print("===============自定义索引===============")
aa = {[1]=1,[2]=2,[5]=4,[6]=5}
for i = 1, #aa do
print(aa[i])
end