Chapter    2

Complex Types

Simple types in programming languages are used to store single values. Examples of simple types include Int, Char, and String. These types can have some methods associated with them, which is similar to a complex type. Think of simple types as the building blocks of complex types.

Complex types are made up of other types and have methods and functions that can operate on data. A custom class you create is an example of a complex type. Swift is an object-oriented language, and creating complex types is the heart of the language. In addition to having classes, Swift offers other data structures to create complex types.

This chapter contains recipes to create new complex types, including classes, enumerations, and structures. ...

Get Swift Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.