> 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/pattern-matching/sentence-patterns/for-case-let-...-where.md).

# for case let ... where

[Swift](/ios/swift.md) ⟩ [Pattern Matching](/ios/swift/pattern-matching.md) ⟩ [Sentence Patterns](/ios/swift/pattern-matching/sentence-patterns.md) ⟩

{% hint style="info" %}

* <mark style="color:red;">**case**</mark>: [pattern matching](/ios/swift/pattern-matching.md).
* <mark style="color:red;">**let**</mark>: variable binding.
* <mark style="color:red;">**where**</mark>: condition on bound variable.
  {% endhint %}

{% tabs %}
{% tab title="💈範例" %}
💾 程式： [Mirror.handleChildren()](/ios/swift/debugging/mirror/mirror.handlechildren.md)

{% hint style="warning" %}
⭐️ 注意： [for case let ... where](/ios/swift/pattern-matching/sentence-patterns/for-case-let-...-where.md) 加條件的方式跟 [if/guard case let](/ios/swift/pattern-matching/sentence-patterns/if-guard-case-let.md) 不一樣❗️
{% endhint %}

```swift
// mirror of `subject`
let mirror = Mirror(reflecting: subject)

// ⭐ for case let ... where 
//   (pattern-match tuples + data binding + condition)
// ------------------------------------------------------
//            ↱ ⭐ child.label ignored     ╭── ⭐ where ───╮
for case let (_, value) in mirror.children where value is T {
    // ...
}

// ⭐ for case let ... where
for case let .loaded(data) in states where data.count > 2
{ ... }
```

{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
⭐️ 注意：下列程式碼**雖然類似** <mark style="color:purple;">**for case let ... where**</mark>，但完全<mark style="color:red;">**沒有用到**</mark> [pattern matching](/ios/swift/pattern-matching.md) 的概念喔❗️

```swift
// for ... in ... where
for item in array where item.year > 2000 { … }
```

{% endhint %}
{% endtab %}

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

* [Mirror.handleChildren()](/ios/swift/debugging/mirror/mirror.handlechildren.md) - use <mark style="color:purple;">**`if case let ... where`**</mark> sentence pattern.
  {% endtab %}
  {% endtabs %}
