summaryrefslogtreecommitdiff
path: root/examples/functions.fy
diff options
context:
space:
mode:
Diffstat (limited to 'examples/functions.fy')
-rw-r--r--examples/functions.fy25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/functions.fy b/examples/functions.fy
new file mode 100644
index 0000000..15856a0
--- /dev/null
+++ b/examples/functions.fy
@@ -0,0 +1,25 @@
+#*
+ * Examples of how to use functions
+ *#
+
+func foo {
+ say 1 + a * 3 + b;
+
+ func bar {
+ say "Hello i am nested";
+ }
+
+ bar; # Calling nested
+}
+
+my a = 2, b = 4; # Create global variables
+foo;
+assert 0 == (defined bar); # bar is not available anymore
+
+func baz {
+ say "I am baz";
+ undef baz;
+}
+
+baz; # Baz deletes itself
+assert 0 == (defined baz); # baz is not available anymore