Typo in Listing 16.6?


I was following along in the second edition of the book and, as instructed in Listing 16.6, modified the ‘townSize’ declaration:

var townSize: Size = {
get {
switch self.population {
case 0…10_000:
return Size.small
case 10_001…100_000:
return Size.medium
return Size.large

But then the error:

Use of unresolved identifier 'get'

immediately pops up in Xcode on the “get {” line.

After double checking my code and seeing that I entered the exact same text as seen in the book (PDF), I downloaded the solutions for chapter 16 from your site and saw that your solution there does not include the equal sign in the initial variable declaration, i.e.:

var townSize: Size {

So I made that change and the error immediately goes away.

Can you confirm that the initial PDF I downloaded is, indeed, in error, and that removing the equals sign is the correct modification to make at that point in the exercise? I ask because the solutions are, I believe, for the first edition of the book. Indeed, in this part of your site, you do not seem to even acknowledge that a second edition of the book is available, let alone perhaps being used by readers.


Actually, upon reading just a few sentences further in the chapter, it’s clear that the reader is, in fact, instructed to remove the equals sign. But, as I think you’ll agree, if the reader uses only the code snippet to make her or his edits (as I did), it’s not at all clear that the equal sign should be removed (because the strike out line that rests on top of the equals sign overlays with uncanny precision the lower horizontal bar of the equal symbol itself–thus rendering the strike out for the equals symbol difficult if not impossible to notice).