# Условные операторы

В Soulver условный оператор выражается в одной строке:

```
earnings = $45k                                 | $45,000.00

if earnings > $30k then tax = 20% else tax = 5% | 20%

My tax paid: earnings × tax                     | $9,000.00
```

**Объявление переменной с использованием условного оператора**

```
income = $35k
expenses = $21.5k

profitable = true if income > expenses     | true
insolvent = false unless expenses > income | false
```

**Использование "and" и "or" в условных операторах**

```
BMI = 24
Underweight = BMI < 18.5                  | false
Healthy Weight = BMI >= 18.5 and BMI < 25 | true
Overweight = BMI >= 25 and BMI < 30       | false
Obese = BMI >= 30                         | false
```

{% hint style="info" %}
&& и || также поддерживаются
{% endhint %}

#### Операторы сравнения и булевы значения

Soulver поддерживает стандартные операторы сравнения в стиле ["C"](https://en.wikipedia.org/wiki/C_\(programming_language\)).

Возвращается булево значение (`true` или `false`).

| Название         | Оператор |
| ---------------- | -------- |
| Равно            | ==       |
| Не равно         | !=       |
| Больше чем       | >        |
| Меньше чем       | <        |
| Больше или равно | >=       |
| Меньше или равно | <=       |

Вы можете присвоить переменной булево значение напрямую

```
cost = $500                                 
discount = true                        
if discount then cost = cost - 10%
cost | $450.00
```

Вы также можете использовать операторы сравнения вне условных операторов

```
20km == 20,000 m   | true
11:30 am < 9:30 am | false
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.soulver.app/ru/spravochnik-po-sintaksisu/general/conditionals-and-comparisons.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
