Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Comparison Operators | Control Structures
Introduction to GoLang

bookComparison Operators

We discussed three comparison operators in previous chapters. However, there are additional operators in this category that we should be familiar with. Below is a list of all the comparison operators:

OperatorLogic
==Equal to
!=Not Equal to
<Less Than
<=Less Than or Equal to
>Greater Than
>=Greater Than or Equal to

Not Equal To (!=)

This operator is used to check if two values are not equal to each other. For example:

index.go

index.go

copy
12
var a int = 1 fmt.Println(a != 2) // Outputs 'true'

Less Than or Equal To (<=)

This operator is used to check if the value on the left is less than or equal to the value on the right:

index.go

index.go

copy
123
var a int = 7 fmt.Println(a <= 7) // Outputs 'true' fmt.Println(a <= 6) // Outputs 'false'

Greater Than or Equal To (>=)

This operator is used to check if the value on the left is greater than or equal to the value on the right:

index.go

index.go

copy
123
var a int = 7 fmt.Println(a >= 7) // Outputs 'true' fmt.Println(a >= 6) // Outputs 'true'
question mark

Which of the following is equivalent to the expression a <= 5 ?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 1

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Awesome!

Completion rate improved to 1.96

bookComparison Operators

Veeg om het menu te tonen

We discussed three comparison operators in previous chapters. However, there are additional operators in this category that we should be familiar with. Below is a list of all the comparison operators:

OperatorLogic
==Equal to
!=Not Equal to
<Less Than
<=Less Than or Equal to
>Greater Than
>=Greater Than or Equal to

Not Equal To (!=)

This operator is used to check if two values are not equal to each other. For example:

index.go

index.go

copy
12
var a int = 1 fmt.Println(a != 2) // Outputs 'true'

Less Than or Equal To (<=)

This operator is used to check if the value on the left is less than or equal to the value on the right:

index.go

index.go

copy
123
var a int = 7 fmt.Println(a <= 7) // Outputs 'true' fmt.Println(a <= 6) // Outputs 'false'

Greater Than or Equal To (>=)

This operator is used to check if the value on the left is greater than or equal to the value on the right:

index.go

index.go

copy
123
var a int = 7 fmt.Println(a >= 7) // Outputs 'true' fmt.Println(a >= 6) // Outputs 'true'
question mark

Which of the following is equivalent to the expression a <= 5 ?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 1
some-alt