CH 26: Swift Review Correction

In Chapter 26, I believe the example for accessing a dictionary is wrong:

“// A dictionary that stores (String, Int) pairs, for example a
// list of people’s names and their ages:
var ages: Dictionary<String, Int>

// Or, using shorthand notation:
var ages: [String: Int]

// Making an instance of the dictionary:
ages = String: Int

// Accessing an object from the dictionary:
var age = dict[“Jony Ive”]”

Excerpt From: Joey deVilla. “iOS Apprentice.” Apple Books.

To access an object from the dictionary should be: var age = ages[“Jony Ive”]

@ganem Can you please help with this when you get a chance? Thank you - much appreciated! :]

Yes, you’re right. There’s a typo here. Thanks for flagging this.

I just verified and this is fixed in the new edition we’re working on.

This topic was automatically closed after 166 days. New replies are no longer allowed.