Debian Codegraph @

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

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