Debian Codegraph @

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

raw
1 = The return Statement
2
3 .Syntax
4 [source,unlang]
5 ----
6 return
7 ----
8
9 The `return` statement is used to exit a processing section such as
10 `authorize`. It behaves similarly to the
11 xref:break.adoc[break] statement, except that it is not limited to
12 being used inside of a xref:foreach.adoc[foreach] loop.
13
14 The `return` statement is not strictly necessary. It is mainly used
15 to simplify the layout of `unlang` policies. If the `return`
16 statement did not exist, then every xref:if.adoc[if] statement might need
17 to have a matching xref:else.adoc[else] statement.
18
19 The `return` statement will also exit a policy which is defined in the
20 `policy { ... } ` subsection. This behavior allows policies to be
21 treated as a function call. Any `return` inside of the policy section
22 will only return from that policy. The `return` will _not_ return
23 from the enclosing processing section which called the policy.
24
25 .Example
26 [source,unlang]
27 ----
28 sql
29 if (&reply.Filter-Id == "hello") {
30 return
31 }
32 ...
33 ----
34
35 // Copyright (C) 2020 Network RADIUS SAS. Licenced under CC-by-NC 4.0.
36 // Development of this documentation was sponsored by Network RADIUS SAS.