November 2016
Intermediate to advanced
480 pages
14h 42m
English
You may be wondering, “Can I put a value type inside of a reference type? Can I put a reference type inside of a value type?” The answer to both of these questions is “Yes,” and you did the latter by adding a property of the class GreekGod to Pantheon. However, although we led you to do this without warning, you must be very careful about using a reference type inside of a value type. (Using a value type inside a reference type does not present any particular problems.) Consider the following example that changes the name of hecate.
Listing 18.12 The Romans are coming
... let pantheon = Pantheon(chiefGod: hecate) let zeus = GreekGod(name: "Zeus") zeus.name = "Zeus Jr." zeus.name pantheon.chiefGod.name ...
Read now
Unlock full access