Mr. Deepak Verma
Web Developer
Comparison Operators

Learn Go Language by M-Learnify

Go Language

Comparison Operators


Go Comparison Operators

Go Comparison Operators

Comparison operators का उपयोग दो values की तुलना करने के लिए किया जाता है।

Note: Comparison का result केवल true या false होता है।

Example: Greater Than (>)

package main
import "fmt"

func main() {
    var x = 5
    var y = 3
    fmt.Println(x > y) // returns true क्योंकि 5, 3 से बड़ा है
}
true

All Comparison Operators

Operator Name Example
==Equal tox == y
!=Not equalx != y
>Greater thanx > y
<Less thanx < y
>=Greater than or equal tox >= y
<=Less than or equal tox <= y
टिप्पणी / Notes:
1. Comparison operators हमेशा वही data types compare करें। जैसे int और int, string और string।
2. Result हमेशा boolean (true या false) होता है।
3. Operator के दोनों side पर proper spacing रखें ताकि code readable रहे।
4. Go में true=1 और false=0 नहीं होते जैसे C में; केवल true/false boolean values होती हैं।
← Back to Courses
Course Lessons