| 1 |
= The if Statement |
| 2 |
|
| 3 |
.Syntax |
| 4 |
[source,unlang] |
| 5 |
---- |
| 6 |
if (condition) { |
| 7 |
[ statements ] |
| 8 |
} |
| 9 |
---- |
| 10 |
|
| 11 |
.Description |
| 12 |
The `if` statement evaluates a xref:condition/index.adoc[condition]. When the |
| 13 |
_condition_ evaluates to `true`, the statements within the subsection |
| 14 |
are executed. When the _condition_ evaluates to `false`, those |
| 15 |
statements are skipped. |
| 16 |
|
| 17 |
An `if` statement can optionally be followed by an xref:else.adoc[else] or |
| 18 |
an xref:elsif.adoc[elsif] statement. |
| 19 |
|
| 20 |
.Example |
| 21 |
[source,unlang] |
| 22 |
---- |
| 23 |
if (&User-Name == "bob") { |
| 24 |
reject |
| 25 |
} |
| 26 |
---- |
| 27 |
|
| 28 |
// Copyright (C) 2020 Network RADIUS SAS. Licenced under CC-by-NC 4.0. |
| 29 |
// Development of this documentation was sponsored by Network RADIUS SAS. |