Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Emanuele Gorga
5,020 Pointsupdate dictionary
Hello guys, I have been trying in many different ways, trying to restart XCODE too but just doesn't want to work out. When I try to use updateValue in order to update a value in the dictionary (but because doesn't find anything it just add a new value), my Xcode is giving me an error:
var airportCodes: [String: String] = ["LGA": "La Guardia", "LHR": "Heathrow", "CDG": "Charles de Gaulle", "HKG": "Hong Kong International", "DXB": "Dubai International"]
airportCodes.updateValue("Dublin Airport", forKey: DUB)
Playground execution failed:
error: SwiftBasics.playground:72:52: error: use of unresolved identifier 'DUB' airportCodes.updateValue("Dublin Airport", forKey: DUB) ^~~
Do you know how to help me out? THANK YOU
1 Answer

Jeff McDivitt
23,970 PointsYou need the quotations around DUB because it is a string
var airportCodes: [String: String] = ["LGA": "La Guardia", "LHR": "Heathrow", "CDG": "Charles de Gaulle", "HKG": "Hong Kong International", "DXB": "Dubai International"]
airportCodes.updateValue("Dublin Airport", forKey: "DUB")
Emanuele Gorga
5,020 PointsEmanuele Gorga
5,020 Pointsyeah perfect now it works :) thank you!