Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.04 KB

comparison-operators.md

File metadata and controls

40 lines (31 loc) · 1.04 KB
layout
default

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