From f11eb0d250412f5aa830c7d0dadee572eeb577d6 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Sun, 4 Nov 2012 13:39:42 -0800 Subject: [PATCH] update docs for assignment in conditionals --- docs/reference.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/reference.md b/docs/reference.md index d121e87..cc6b871 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -646,6 +646,8 @@ Conditionals can also be used in return statements and assignments: print message -- prints: I am very tall ``` +### With Assignment + `if` and `elseif` blocks can take an assignment in place of a conditional expression. Upon evaluating the conditional, the assignment will take place and the value that was assigned to will be used as the conditional expression. The @@ -657,6 +659,15 @@ is never available if the value is not truthy. print user.name ``` + ```moon + if hello = os.getenv "hello" + print "You have hello", hello + elseif world = os.getenv "world" + print "you have world", world + else + print "nothing :(" + ``` + ## Line Decorators For convenience, the for loop and if statement can be applied to single