Conditional structures: Difference between revisions

Content added Content deleted
Line 3,779: Line 3,779:
===if expressions===
===if expressions===
If expressions are scoped per section.
If expressions are scoped per section.
<syntaxhighlight lang="langur"># using the fact that submatch() returns an empty array for no match ...
<syntaxhighlight lang="langur">if .x == 0 {
# ... and that a decoupling assignment returns a Boolean...

if val .alias, .name = submatch($re/^(\.idregex;)\\s*;\\s*(\.idregex;)/, .row) {
# success (2 or more values in array returned from submatch function)
# use .alias and .name here
...
...
} else if .x > 0 {
} else if .x > 0 {
Line 3,793: Line 3,788:
...
...
}</syntaxhighlight>
}</syntaxhighlight>

Prior to langur 0.10, you would use parentheses around the declared variable names (.alias, .name).


===shortened form if expression===
===shortened form if expression===