Lessons
Go Introduction
Go Get Started
Go Syntax
Go Comments
Go Variables
- Declare Variables
- Go में Variables का परिचय
- Go में Multiple Variable Declaration
- Variable Naming Rules (नामकरण के नियम)
Go Constants
Go Output
Go Data Types
- Basic Data Types
- Go Boolean Data Type (बूलियन डेटा प्रकार)
- Go Integer Data Types
- Go Float Data Types
- Go String Data Type
Go Arrays
Go Slices
Go Operators
- Go Operators
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Bitwise Operators
Go Conditions
Go Switch
Go Loops
Go Functions
Go Struct
Go Maps
Project Structure
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 to | x == y |
| != | Not equal | x != y |
| > | Greater than | x > y |
| < | Less than | x < y |
| >= | Greater than or equal to | x >= y |
| <= | Less than or equal to | x <= y |
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 होती हैं।