> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/redscript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/redscript/language/language-features/loops.md).

# Loops

REDscript supports two types of loops: `while` and `for..in`.

{% hint style="info" %}
Unlike Swift, REDScript does not support `continue`. If you want to skip a loop, you need to execute it in a function and `return`.
{% endhint %}

### while

You can use the `while` statement to repeatedly execute a block of code as long as a condition is true. This is similar to how it works in many other languages. For example, you can use a while loop to print each element of an array:

```swift
let i = 0;
let array = ["a", "b", "c"];

while i < ArraySize(array) {
  let elem = array[i];
  Log(elem);
  i += 1;
}
// will log a, b and c
```

### for..in

You can use the `for..in` statement to iterate through all the elements of an array one by one. It's often cleaner than using an explicit `while` loop:

```swift
let array = ["a", "b", "c"];

for elem in array {
  Log(elem);
}
// will log a, b and c
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/redscript/language/language-features/loops.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
