aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/tutorial.nom27
1 files changed, 21 insertions, 6 deletions
diff --git a/examples/tutorial.nom b/examples/tutorial.nom
index 776f900..55e558b 100644
--- a/examples/tutorial.nom
+++ b/examples/tutorial.nom
@@ -52,12 +52,27 @@ if (1 > 10):
..else:
say "this will print"
-if (1 > 3):
- say "this won't print"
-..else: if (1 < 2):
- say "this won't print"
-..else:
- say "this will print"
+# For longer conditionals, a "when" branch is the best option
+when:
+ ? 1 > 4:
+ say "this won't print"
+ ? 1 > 3:
+ say "this won't print"
+ ? 1 > 2:
+ say "this won't print"
+ ?:
+ say "this will print"
+
+# When "when" is given an argument, it works like a switch statement
+when 3:
+ == 1:
+ say "this won't print"
+ == 2:
+ say "this won't print"
+ == 3:
+ say "this will print"
+ ==:
+ say "this won't print"
# Loops look like this:
for %x in [1,2,3]: