switch {
case {
[ statements-1 ]
}
case {
[ statements-2 ]
}
case {
[ statements-3 ]
}
}
The switch Statement
A switch
statement causes the server to evaluate expansion, which
can be an &Attribute-Name or data.
The result is compared against match-1 and match-2 to find a
match. If no string matches, then the server looks for the default
case statement, which has no associated match.
The matching is done via equality. The switch
statement is mostly
syntactic sugar and is used to simplify the visual form of the
configuration. It is mostly equivalent to the following use of
if statements:
if ( == ) {
[ statements-1 ]
}
elsif ( == ) {
[ statements-2 ]
}
else {
[ statements-3 ]
}
The only difference between the two forms is that for a switch
statement, the expansion is evaluated only once. For the equivalent
if statement, the expansion is evaluated again for every
if.
If a matching case is found, the statements within that
case are evaluated. If no matching case is
found, the "default" case is evaluated. This default is the
case with no match text. If there is no default
case, then the switch
statement does nothing.
The match text for the case statement can be an &Attribute-Name or data.