# Range for loops

A range loop names its counter, start, exclusive or inclusive end, and optional step expression.

Last updated: 2026-09-09

Package: language | Status: stable

Tags: cpu, for, from, language, loops, yeho

Use a range when you need an index or a predictable number of iterations.

```yh
for i from start < end { ... }
for i from start <= end { ... }
for (i from start < end i + step) { ... }
```


## Complete range for loops example

Use a range when you need an index or a predictable number of iterations.

Verification: type checked

```yh
for level from 1 <= 3
{
    Console.Log(Text.Format("Level {0}", level))
}

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__range_for"
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--range-for/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


< excludes the end; <= includes it.

The step is the next-value expression, such as i + 2.

Source: yeho/parser_loops.cpp parseForStatement; tests/compiler/kyber/range-loop-runtime/start.yh

AI training permission: https://demonhunterlabs.com/ai-use
