> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/NormandoRamirezDelgado/6C-Febrero-2026/llms.txt
> Use this file to discover all available pages before exploring further.

# Comparison Operators

> Learn how to compare values in Dart using comparison operators

## Overview

Comparison operators (also called relational operators) are used to compare two values. They always return a boolean value: `true` or `false`.

## Comparison Operators Table

| Operator | Description              | Example    | Result  |
| -------- | ------------------------ | ---------- | ------- |
| `==`     | Equal to                 | `18 == 18` | `true`  |
| `!=`     | Not equal to             | `18 != 18` | `false` |
| `>`      | Greater than             | `18 > 17`  | `true`  |
| `<`      | Less than                | `18 < 18`  | `false` |
| `>=`     | Greater than or equal to | `18 >= 18` | `true`  |
| `<=`     | Less than or equal to    | `18 <= 18` | `true`  |

## Basic Example

Here's a complete example demonstrating all comparison operators:

```dart theme={null}
void main() {
  int edad = 18;

  print(edad == 18);   // Igual: true
  print(edad != 18);   // Diferente: false
  print(edad > 17);    // Mayor que: true
  print(edad < 18);    // Menor que: false
  print(edad >= 18);   // Mayor o igual: true
  print(edad <= 18);   // Menor o igual: true
}
```

**Output:**

```
true
false
true
false
true
true
```

<Note>
  Comparison operators are essential for control flow statements like `if`, `while`, and `for` loops.
</Note>

## Understanding Equality

### Equal (`==`) vs Not Equal (`!=`)

```dart theme={null}
int x = 5;
int y = 10;

print(x == y);  // false (5 is not equal to 10)
print(x != y);  // true (5 is different from 10)
```

<Warning>
  In Dart, use `==` for equality comparison, not `=`. The single `=` is the assignment operator!

  * `x == 5` checks if x equals 5
  * `x = 5` assigns 5 to x
</Warning>

## Range Comparisons

### Greater Than and Less Than

```dart theme={null}
int score = 85;

print(score > 90);   // false
print(score > 80);   // true
print(score < 100);  // true
print(score < 85);   // false
```

### Inclusive Comparisons

The `>=` and `<=` operators include the boundary value:

```dart theme={null}
int age = 18;

print(age >= 18);  // true (18 is included)
print(age > 18);   // false (must be greater, not equal)

print(age <= 18);  // true (18 is included)
print(age < 18);   // false (must be less, not equal)
```

<Tip>
  Use `>=` and `<=` when you want to include the boundary value in your comparison. For example, "age must be 18 or older" would use `age >= 18`.
</Tip>

## Practical Examples

### Age Verification

```dart theme={null}
int userAge = 20;
bool isAdult = userAge >= 18;
print(isAdult);  // Output: true
```

### Password Length Check

```dart theme={null}
String password = "mypass123";
bool isValidLength = password.length >= 8;
print(isValidLength);  // Output: true
```

### Grade Evaluation

```dart theme={null}
int grade = 75;
bool passed = grade >= 60;
bool excellence = grade >= 90;

print('Passed: $passed');        // Output: Passed: true
print('Excellence: $excellence'); // Output: Excellence: false
```

### Range Checking

```dart theme={null}
int temperature = 22;
bool isComfortable = temperature >= 18 && temperature <= 25;
print(isComfortable);  // Output: true
```
