Go Comparison Operators

Gayathri. B

 Comparison Operators in Go

  • Comparison operators evaluate the relationship between two values and return a Boolean result—true (displayed as 1) or false (displayed as 0).
  • Below, the greater‑than operator (>) checks whether 5 is larger than 3:

Example:

package main
import "fmt"
func main() {
    x := 5
    y := 3
    fmt.Println(x > y) // Outputs: 1 (true) because 5 is greater than 3
}
Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send