mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
update docs for assignment in conditionals
This commit is contained in:
parent
51a75272a3
commit
f11eb0d250
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user