特定のクラスや構造体の機能をサポートするために、列挙型を作ることがよくあります。同じようにして、複雑な型のコンテキスト内でのみ使用するユーティリティのクラスや構造体を定義すると使いやすくなります。これを実現するために、Swift では型の定義内に、サポートする列挙型やクラス、構造体をネストさせて型を定義することができます。

型の内側に別の型をネストするには、サポートする型の外側の波括弧内に定義を記述します。


Portions of this page are translations based on work created and shared by Apple and used according to terms described in the Creative Commons Attribution 4.0 International License.