Trouble with "get" in Chapter 16, Properties


I’m new to Swift 4, using Swift Programming: The Big Nerd Ranch Guide 2/e to learn it. I encounter the following code a few pages into Chapter 16, Properties (it’s location 4690 in the Kindle edition):

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




When I duplicate this code in XCode, I get the following error: "Use of unresolved identifier ‘get’ "

As I understand it, “get” is supposed to signal to use the following closure to get a computed property. But XCode is apparently treated it as an identifier.

This is the first time I’ve hit a wall with this book. I’d be grateful for any help. Is it possible that this reflects a change in Swift since after the book was published?


I just realized another person had this same issue – and get it resolved already.