December 2015
Intermediate to advanced
400 pages
13h 3m
English
Nested types are types that are defined within another enclosing type. They are often used to support the functionality of a type and are not intended to be used separately from that type. You have seen nested functions already, which are similar.
Enumerations are frequently nested. In Town.swift, create a new enumeration called Size. You will be using this enumeration, in coordination with another new property to be added later, to calculate whether the town can be designated as small, medium, or large. Make sure that you define the enum within the definition for the Town struct.
Listing 16.2 Setting up the Size enum (Town.swift)
struct Town { let region = "South" var population = 5422 var numberOfStoplights = ...Read now
Unlock full access