15 Structs and Classes

Structures (commonly referred to as structs) and classes are the pillars on which you build your applications. They provide important mechanisms to model the things you wish to represent in your code.

You are going to transition from the playground and create a command-line tool, which you will work in for the next several chapters. Your command-line tool project will represent a town undergoing a serious monster infestation. You will use both structs and classes to model these entities and will give them properties to store data and functions so that these entities can do some work.

As you will see, structs and classes have similarities and differences. Which to use for any particular situation is an important ...

Get Swift Programming: The Big Nerd Ranch Guide 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.