# While loops

while repeats a block while its bool condition remains true.

Last updated: 2026-09-09

Package: language | Status: stable

Tags: cpu, language, loops, while, yeho

Use while when the stopping condition is more natural than a known collection or numeric range.

```yh
while condition { ... }
```


## Complete while loops example

Use while when the stopping condition is more natural than a known collection or numeric range.

Verification: type checked

```yh
int health = 30
while health > 0
{
    Console.Log(Text.From(health))
    health = health - 10
}

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__while_loop"
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--while-loop/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


The condition must be bool.

Update the condition's inputs inside the loop unless an external event owns progress.

Source: yeho/parser_statements.cpp parseWhileStatement; Kyber loop runtime fixtures

AI training permission: https://demonhunterlabs.com/ai-use
