# If, else if, and else

if branches on a bool expression. Parentheses around the condition are optional, and each branch uses a block.

Last updated: 2026-09-09

Package: language | Status: stable

Tags: cpu, else, if, language, logic, yeho

Use if for a small number of ordered decisions. Use match when one value has several named shapes or cases.

```yh
if condition { ... }
else if condition { ... }
else { ... }
```


## Complete if, else if, and else example

Use if for a small number of ordered decisions. Use match when one value has several named shapes or cases.

Verification: type checked

```yh
int coins = 20
if coins >= 15 { Console.Log("You can buy the shield") }
else { Console.Log("Collect more coins") }

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__if_else"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/language--if-else/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


The condition must be bool.

Keep the most specific or highest-priority branch first.

Source: yeho/parser_statements.cpp parseIfStatement; conformance control.boolean-conditions

AI training permission: https://demonhunterlabs.com/ai-use
