Debian Codegraph @

doc/antora/modules/unlang/pages/default.adoc

raw
1 = The case Statement
2
3 .Syntax
4 [source,unlang]
5 ----
6 case [ <match> ] {
7 [ statements ]
8 }
9 ----
10
11 The `case` statement is used to match data inside of a
12 xref:switch.adoc[switch] statement. The `case` statement cannot be used
13 outside of a xref:switch.adoc[switch] statement.
14
15
16 The `<match>` text can be an attribute reference such as `&User-Name`,
17 or it can be a xref:type/index.adoc[string]. If the match
18 text is a dynamically expanded string, then the match is performed on
19 the output of the string expansion.
20
21 The keyword `default` can be used to specify the default action to
22 take inside of a xref:switch.adoc[switch] statement.
23
24 If no `<match>` text is given, it means that the `case` statement is
25 the "default" and will match all which is not matched by another
26 `case` statement inside of the same xref:switch.adoc[switch].
27
28 .Example
29 [source,unlang]
30 ----
31 switch &User-Name {
32 case "bob" {
33 reject
34 }
35
36 case &Filter-Id {
37 reject
38 }
39
40 default {
41 ok
42 }
43 }
44 ----
45
46 // Copyright (C) 2020 Network RADIUS SAS. Licenced under CC-by-NC 4.0.
47 // Development of this documentation was sponsored by Network RADIUS SAS.