Debian Codegraph @

docs/content/en/functions/compare/Le.md

raw
1 ---
2 title: compare.Le
3 description: Reports whether the first argument is less than or equal to all of the subsequent arguments.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [le]
9 returnType: bool
10 signatures: ['compare.Le ARG1 ARG2 [ARG...]']
11 aliases: [/functions/le]
12 ---
13
14 ## Usage
15
16 The `compare.Le` function reports whether the first argument is less than or equal to all of the subsequent arguments. Numbers are compared by value, regardless of type. You can also use this function to compare strings, boolean values, dates, and other comparable data types.
17
18 ## Examples
19
20 ```go-html-template
21 {{ compare.Le 1 1 }} → true
22 {{ compare.Le 1 2 }} → true
23 {{ compare.Le 2 1 }} → false
24
25 {{ compare.Le 1 1 1 }} → true
26 {{ compare.Le 1 1 2 }} → true
27 {{ compare.Le 1 2 1 }} → true
28 {{ compare.Le 1 2 2 }} → true
29
30 {{ compare.Le 2 1 1 }} → false
31 {{ compare.Le 2 1 2 }} → false
32 {{ compare.Le 2 2 1 }} → false
33 ```
34
35 Comparing numbers of different types:
36
37 ```go-html-template
38 {{ compare.Le 1 1.0 }} → true
39 ```
40
41 Comparing other data types:
42
43 ```go-html-template
44 {{ compare.Le "ab" "a" }} → false
45 {{ compare.Le time.Now (time.AsTime "1964-12-30") }} → false
46 {{ compare.Le true false }} → false
47 ```