update docs for assignment in conditionals

This commit is contained in:
leaf corcoran 2012-11-04 13:39:42 -08:00
parent 51a75272a3
commit f11eb0d250

View File

@ -646,6 +646,8 @@ Conditionals can also be used in return statements and assignments:
print message -- prints: I am very tall print message -- prints: I am very tall
``` ```
### With Assignment
`if` and `elseif` blocks can take an assignment in place of a conditional `if` and `elseif` blocks can take an assignment in place of a conditional
expression. Upon evaluating the conditional, the assignment will take place and 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 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 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 ## Line Decorators
For convenience, the for loop and if statement can be applied to single For convenience, the for loop and if statement can be applied to single