Jump to content

Conditional structures: Difference between revisions

Add DM language example
(→‎{{header|jq}}: mention //)
(Add DM language example)
Line 1,450:
 
:''See [[Conditional Structures#Pascal|Pascal]]''
 
=={{header|DM}}==
===if-elseif-else===
<lang DM>if (condition)
// Do thing, DM uses indentation for control flow.
 
if (condition)
// Do thing
 
else if (condition)
// Do thing
 
else
// Do thing
</lang>
 
===Ternary===
<lang DM>// x will be 1 if condition is a true value, 2 otherwise.
var/x = condition ? 1 : 2
</lang>
 
===Switch===
<lang DM>switch (value)
if (0)
// Do thing if zero
// DM does not have fall through of switch cases, so explicit break is not required.
if (1, 2, 3)
// Multiple values can be allowed by using commas
 
if (10 to 20)
// Ranges are also allowed.
// Ranges include the bounds (10 and 20 here),
// and are checked in order if there is potential for overlap.
 
else
// Fallback if nothing was matched.
</lang>
 
=={{header|DWScript}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.