Anonymous user
Conditional structures: Difference between revisions
→{{header|AWK}}: with braces
m (Fix the Dao example.) |
(→{{header|AWK}}: with braces) |
||
Line 329:
Conditionals in awk are modelled after C:
<lang awk>if(i<0) i=0; else i=42</lang>
For a branch with more than a single statement, this needs braces:
including the ternary conditional▼
<lang awk>
if(i<0) {
i=0; j=1
} else {
i=42; j=2
}</lang>
<lang awk>i=(i<0? 0: 42)</lang>
|