8 Structs
Structs are special types in Swift; they are similar to classes but offer a different mechanism. Therefore, this topic is placed before classes to offer a gradual warm-up. It is a challenge to split features between this topic and classes as the data structure mechanisms greatly overlap. Our strategy is to keep this topic at a relatively basic level and move to more advanced topics in the class and protocol chapters. Features that also work for structs will be highlighted and demonstrated there as well.
In the previous chapter, you learned about enumerations, which are ideal to consolidate constants centrally, under a common umbrella. They also offer empowering features like computed properties and functions. In the next chapter, you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access