Debian Codegraph @

docs/content/en/functions/go-template/or.md

raw
1 ---
2 title: or
3 description: Returns the first truthy argument. If all arguments are falsy, returns the last argument.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: []
9 returnType: any
10 signatures: [or VALUE...]
11 ---
12
13 {{% include "/_common/functions/truthy-falsy.md" %}}
14
15 The `or` function evaluates the arguments from left to right, and returns when the result is determined.
16
17 ```go-html-template
18 {{ or 0 1 2 }} → 1 (int)
19 {{ or false "a" 1 }} → a (string)
20 {{ or 0 true "a" }} → true (bool)
21
22 {{ or false "" 0 }} → 0 (int)
23 {{ or 0 "" false }} → false (bool)
24
25 {{ or true (math.Div 1 0) }} → true (bool)
26 ```
27
28 {{% include "/_common/functions/go-template/text-template.md" %}}