> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/syntax_and_semantics/constructs/while.md).

# While

The `while` construct is almost like the `if` construct, except that it will keep executing its block as long the given expression is true.

```ruby
var n = 10

while (n > 0) {
    say n
    n -= 1
}
```
