| 1 |
--- |
| 2 |
title: compare.Gt |
| 3 |
description: Reports whether the first argument is greater than all of the subsequent arguments. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [gt] |
| 9 |
returnType: bool |
| 10 |
signatures: ['compare.Gt ARG1 ARG2 [ARG...]'] |
| 11 |
aliases: [/functions/gt] |
| 12 |
--- |
| 13 |
|
| 14 |
## Usage |
| 15 |
|
| 16 |
The `compare.Gt` function reports whether the first argument is greater than 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.Gt 1 1 }} → false |
| 22 |
{{ compare.Gt 1 2 }} → false |
| 23 |
{{ compare.Gt 2 1 }} → true |
| 24 |
|
| 25 |
{{ compare.Gt 1 1 1 }} → false |
| 26 |
{{ compare.Gt 1 1 2 }} → false |
| 27 |
{{ compare.Gt 1 2 1 }} → false |
| 28 |
{{ compare.Gt 1 2 2 }} → false |
| 29 |
|
| 30 |
{{ compare.Gt 2 1 1 }} → true |
| 31 |
{{ compare.Gt 2 1 2 }} → false |
| 32 |
{{ compare.Gt 2 2 1 }} → false |
| 33 |
``` |
| 34 |
|
| 35 |
Comparing numbers of different types: |
| 36 |
|
| 37 |
```go-html-template |
| 38 |
{{ compare.Gt 1 1.0 }} → false |
| 39 |
``` |
| 40 |
|
| 41 |
Comparing other data types: |
| 42 |
|
| 43 |
```go-html-template |
| 44 |
{{ compare.Gt "ab" "a" }} → true |
| 45 |
{{ compare.Gt time.Now (time.AsTime "1964-12-30") }} → true |
| 46 |
{{ compare.Gt true false }} → true |
| 47 |
``` |