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