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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.