> 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/statement/do.md).

# do

🚧 施工中

[Swift](/ios/swift.md) ⟩ [statement](/ios/swift/statement.md) ⟩ do

{% hint style="success" %}
a [statement](/ios/swift/statement.md) that is used to introduce a <mark style="color:yellow;">**new scope**</mark> and can <mark style="color:orange;">**optionally**</mark> contain one or more <mark style="color:blue;">`catch`</mark> <mark style="color:yellow;">**clauses**</mark>, which contain [patterns](/ios/swift/pattern-matching.md) that <mark style="color:yellow;">**match against**</mark> defined <mark style="color:yellow;">**error**</mark> conditions. (similar to <mark style="color:yellow;">**curly braces**</mark> (<mark style="color:blue;">`{}`</mark>) in C used to delimit a <mark style="color:yellow;">**code block**</mark>)
{% endhint %}

{% tabs %}
{% tab title="🧨 雷區" %}
{% hint style="danger" %}
⛔ <mark style="color:red;">**error**</mark>: <mark style="color:yellow;">**unlabeled**</mark> [break](/ios/swift/flow/transfer/break.md) is only allowed <mark style="color:yellow;">**inside**</mark> a [loop](/ios/swift/flow/loop.md) or [switch](/ios/swift/flow/branch/switch.md), a <mark style="color:yellow;">**labeled**</mark> [break](/ios/swift/flow/transfer/break.md) is <mark style="color:orange;">**required**</mark> to exit an [if](/ios/swift/flow/branch/if.md) or [do](/ios/swift/statement/do.md).\
( 👉 see: [for...in vs. forEach](/ios/swift/flow/loop/for...in-vs.-foreach.md) )
{% endhint %}
{% endtab %}

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

* [Statements](https://docs.swift.org/swift-book/ReferenceManual/Statements.html) ⟩ [do statement](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID533)
  {% endtab %}

{% tab title="🗣 討論" %}

* [UI: do { } in Swift](https://stackoverflow.com/questions/55293363/ui-do-in-swift)
  {% endtab %}

{% tab title="🚧" %}

* catch clause
  {% endtab %}
  {% endtabs %}
