summaryrefslogtreecommitdiffstats
path: root/table.lua
blob: d3ef7baf6627934b566308180a18a18c096a75e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- print array of values --
t0 = { 1,3,7,12,13,21,33,42 }
t0["oops"] = "what will happen" -- nothing --
for i in ipairs(t0) do
    print(t0[i])
end

-- print t0 array backwards --
-- the for loop, initialization, condition, step --
for i = #t0, 1, -1 do
    print(t0[i])
end

-- print array of string where a key is of type string (dictionary) --
t1 = { name = "Kyle", ["age"] = 22, ["my status"] = "amused" }

for k, v in pairs(t1) do
    print(k,v)
end