> For the complete documentation index, see [llms.txt](https://documentation.soulver.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.soulver.app/ja/rifarensu/general/conditionals-and-comparisons.md).

# 条件分岐

Soulverでは、条件分岐は1行で記述されます。

```
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
```

if文の外側でも比較演算子を使用できます。

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