summaryrefslogtreecommitdiffstats
path: root/scope.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scope.lua')
-rw-r--r--scope.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/scope.lua b/scope.lua
new file mode 100644
index 0000000..eecd804
--- /dev/null
+++ b/scope.lua
@@ -0,0 +1,20 @@
+-- scope --
+
+do
+ -- variable y not in global scope anymore --
+ local y = 21
+end
+
+function foo()
+ -- on the first foo call, the x below will be defined globally --
+ -- oy oy oy ooooooy --
+ x = 13;
+
+ -- y is not seen here --
+ print(y)
+end
+
+print(x) -- no x defined --
+foo()
+print(x) -- x defined after call to foo --
+