> 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/switch-case-let-...-as.md).

# switch case let ... as

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

{% tabs %}
{% tab title="💈範例" %}
👉 比較： [if let ... as?](/ios/swift/pattern-matching/sentence-patterns/if-let-...-as.md)

```swift
// switch on "protocol type"
switch medium {
  case let b as Book : // ... ⭐️ 注意：這裡用的是 `as` 不是 `as?`
  case let m as Movie: // ...
  default: // ...
}
```

{% endtab %}

{% tab title="📗 參考" %}

* AliSoftware ⟩ Pattern Matching&#x20;
  * [x] [Part 1: switch, enums & where clauses](https://alisoftware.github.io/swift/pattern-matching/2016/03/27/pattern-matching-1/)
  * [ ] [Part 2: tuples, ranges & types](https://alisoftware.github.io/swift/pattern-matching/2016/03/30/pattern-matching-2/) ⭐️
    {% endtab %}

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

* [if let ... as?](/ios/swift/pattern-matching/sentence-patterns/if-let-...-as.md) - use <mark style="color:red;">**`as?`**</mark>.
  {% endtab %}
  {% endtabs %}
