summaryrefslogtreecommitdiffstats
path: root/function.lua
diff options
context:
space:
mode:
Diffstat (limited to 'function.lua')
-rw-r--r--function.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/function.lua b/function.lua
new file mode 100644
index 0000000..e46da78
--- /dev/null
+++ b/function.lua
@@ -0,0 +1,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)
+