File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,17 @@ Conditionals can also be used in return statements and assignments:
592592 print message -- prints: I am very tall
593593 ```
594594
595+ ` if ` and ` elseif ` blocks can take an assignment in place of a conditional
596+ expression. Upon evaluating the conditional, the assignment will take place and
597+ the value that was assigned to will be used as the conditional expression. The
598+ assigned variable is only in scope for the body of the conditional, meaning it
599+ is never available if the value is not truthy.
600+
601+ ```moon
602+ if user = database\find_user "moon"
603+ print user.name
604+ ```
605+
595606## Line Decorators
596607
597608For convenience, the for loop and if statement can be applied to single
You can’t perform that action at this time.
0 commit comments