go-examples

Get Set Learn Go


Project maintained by sagar-jadhav Hosted on GitHub Pages — Theme by mattgraham

Comparison Operators

Example demonstrates different comparison operators in Go. Comparison operators are used to evaluate values to boolean value of either true or false. Click here to learn more

func main() {
	x := 3
	y := 5

	fmt.Println("x == y =", x == y)
	fmt.Println("x != y =", x != y)
	fmt.Println("x < y  =", x < y)
	fmt.Println("x > y  =", x > y)
	fmt.Println("x <= y =", x <= y)
	fmt.Println("x >= y =", x >= y)
}

Output

x == y = false
x != y = true
x < y  = true
x > y  = false
x <= y = true
x >= y = false
Try It Out Source Code

Contributors

« Home Page Previous « Boolean Expressions Next » Math functions