Conditional structures: Difference between revisions

Line 2,909:
 
=={{header|Langur}}==
If and given expressions always produce values.a Ifvalue, no else/default is specified,even theyif mightit's producenothing (null).
 
In the shortened forms, you dispense with the keywords (except the first one).
Line 2,934:
 
===given===
Given expressions are highly flexible. See the langur websitelangurlang.org for more details.
 
Given expressions are scoped per block. Also, test expressions may contain declarations which are scoped to the entire expression. Conditions (case statements) may not contain declarations.
Line 2,940:
case true: ... # all are true
case false, _: ... # .x == false
case 7_, 14null, 21true: ... # .x == 7 and .y == 14null and .z == 21true
}</lang>
case or > 100, _, re/abc/: ... # .x > 100 or matching(re/abc/, .z)
 
case ; .a > .b: ... # .a > .b
<lang Langur>given .x, .y, != .z {
case _, _, 7; xor .a <= .b: ... # .z == 7 xor .a <= .b
case 7 <, 14, 21: ... # 7 < .x and .y == 14 and .z != 21
case or > 100, _, re/abc/: ... # .x > 100 or matching(re/abc/, .z)
case ; .a > .b: ... # .a > .b
case _, _, == 7; xor .a <= .b: ... # .z == 7 xor .a <= .b
default: ...
}</lang>
990

edits