Conditional structures: Difference between revisions

PascalABC.NET
(Add Ed conditionals)
(PascalABC.NET)
 
(One intermediate revision by one other user not shown)
Line 2,505:
=={{header|Ed}}==
 
Note that ed, unlike more advanced [[Sed]], has no conditional branching. Still, conditionals can be simulated with global match/no-match rules:
 
<syntaxhighlight lang="bash">
g/True/s//It's true!/p
v/True/s/.*/It's false!/p
Line 5,529:
 
PARI can use all of the usual [[Conditional structures/C|C conditionals]].
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
// if statement
if condition then
operator;
 
if condition then
operator
else operator;
 
if condition then
operator
else if condition then
operator
else operator;
 
// case statement
case Month of
3..5: Print('Spring');
6..8: Print('Summer');
9..11: Print('Autumn');
12,1,2: Print('Winter');
else throw ArgumentException('Bad Month')
end;
 
// ternary operator
var min := if a < b then a else b;
 
// ternary operator in C style
var min := a < b ? a : b;
</syntaxhighlight>
 
=={{header|Pascal}}==
246

edits