# any

[Swift](https://lochiwei.gitbook.io/ios/swift) ⟩ [Features](https://lochiwei.gitbook.io/ios/features) ⟩ [5.6](https://lochiwei.gitbook.io/ios/features/swift/5.6) ⟩ any

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
這個新的關鍵字是對使用 "<mark style="color:red;">**existential types**</mark>" 的一種「<mark style="color:orange;">**標示**</mark>」，或可說是「<mark style="color:orange;">**警示**</mark>」：

```swift
// ⭐️ it's OK for now (Swift: < 6.0 ✅, >= 6.0 ❌)
let a: SomeProtocol

// ⭐️ 'any' is required in Swift 6.0
let a: any SomeProtocol
```

{% endhint %}

{% hint style="success" %}
the <mark style="color:red;">**`any`**</mark> keyword simply annotates that a given type is a so-called <mark style="color:orange;">**existential**</mark> ... existentials are <mark style="color:orange;">**relatively expensive**</mark> to use because the compiler and runtime **can’t pre-determine** how much memory should be allocated for the concrete object that will fill in the existential ... the <mark style="color:orange;">**cost**</mark> of <mark style="color:orange;">**using existential types**</mark> should **not be hidden**, and programmers should **explicitly** <mark style="color:red;">**opt into**</mark> these semantics.

👉 Donny ⟩ [What is the “any” keyword in Swift?](https://www.donnywals.com/what-is-the-any-keyword-in-swift/)
{% endhint %}
{% endtab %}

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

* Donny ⟩ [What is the “any” keyword in Swift?](https://www.donnywals.com/what-is-the-any-keyword-in-swift/)
* Swift ⟩ [Swift 5.6 Released!](https://www.swift.org/blog/swift-5.6-released/)
  {% endtab %}

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

* compare: [some](https://lochiwei.gitbook.io/ios/swift/type/category/some-any-generics/some "mention") (:key2: <mark style="color:red;">**some**</mark>)
  {% endtab %}
  {% endtabs %}
