> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swift/flow.md).

# flow control

[Swift](/ios/swift.md) ⟩ flow control

{% hint style="success" %}
a [statement](/ios/swift/statement.md) that controls the <mark style="color:yellow;">**flow of execution**</mark> in a program.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %}
Swift provides a variety of <mark style="color:purple;">**control flow**</mark> [statement](/ios/swift/statement.md)s. These include：

* [loop](/ios/swift/flow/loop.md) statements to perform a task <mark style="color:yellow;">**multiple times**</mark>.
* [branch](/ios/swift/flow/branch.md) statements to execute <mark style="color:yellow;">**different branches**</mark> of code based on certain <mark style="color:yellow;">**conditions**</mark>.
* [control transfer](/ios/swift/flow/transfer.md) statements to <mark style="color:yellow;">**transfer**</mark> the flow of execution to <mark style="color:yellow;">**another point**</mark> in your code.
  {% endhint %}
  {% endtab %}

{% tab title="🔴 主題" %}

* <mark style="color:yellow;">**types of**</mark>**&#x20;**<mark style="color:purple;">**control flow**</mark> [statement](/ios/swift/statement.md)s
  * [loop](/ios/swift/flow/loop.md)
    * [for...in](/ios/swift/flow/loop/for...in.md), while 🚧, repeat...while 🚧
  * [branch](/ios/swift/flow/branch.md)
    * [if](/ios/swift/flow/branch/if.md), [switch](/ios/swift/flow/branch/switch.md), [guard](/ios/swift/flow/branch/guard.md)
  * [control transfer](/ios/swift/flow/transfer.md)
    * break, continue, fallthrough, throw, return 🚧
      {% endtab %}

{% tab title="👥 相關" %}

* <mark style="color:purple;">**flow control**</mark> is a [statement](/ios/swift/statement.md). (control flow statement)
  {% endtab %}

{% tab title="📘 手冊" %}

* [ ] [Statements](https://docs.swift.org/swift-book/ReferenceManual/Statements.html)
  {% endtab %}
  {% endtabs %}


---

# 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, and the optional `goal` query parameter:

```
GET https://lochiwei.gitbook.io/ios/swift/flow.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
