Comparison operators compare two values and produce a boolean result.
| Operator | Meaning |
|---|---|
== | equal to |
!= | not equal to |
< | less than |
<= | less than or equal to |
> | greater than |
>= | greater than or equal to |
grade := 8
if grade < 5 {
fmt.Println("Failed the test")
} else {
fmt.Println("Passed the test")
}
Assignment
Use a comparison to decide whether the grade is passing.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
