Permalink
Browse files

update docs for assignment in conditionals

  • Loading branch information...
1 parent 51a7527 commit f11eb0d250412f5aa830c7d0dadee572eeb577d6 @leafo committed Nov 4, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 docs/reference.md
View
11 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

0 comments on commit f11eb0d

Please sign in to comment.