summaryrefslogtreecommitdiffstats
path: root/function.lua
blob: e46da780affab3326bf1a3a1df0532eba12fe3bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- simple function --
function checkAge(t)
    if ((t.age and "he entered valid age") == nil) then
        print("no age")
    else
        print("he entered his age")
    end
end

function printDict(t, flag)
    for k, v in pairs(t) do
        if (flag ~= nil) then
            print(k)
        else
            print(k, v)
        end
    end
end

t1 = { name = "Kyle", ["age"] = 22, ["my status"] = "amused" }
print("checking age... ")
checkAge(t1)
printDict(t1, nil)