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.


Alex Ferguson
Alex Ferguson
2,518 Points

Data modeling with structures challenge 2 of 2

Retrieve the language used for iOS development by using the relevant key and dictionary subscripting notation and store it in a variable named iosLanguage.

this is what i wrote i dont know whats wrong with it though

let languages = ["iOS": "Swift", "Android":"Java"]
var iosLanguage: String = ["iOS: Swift"]

1 Answer

Stone Preston
Stone Preston
42,016 Points

you need to use dictionary subscripting notation. dictionary subscripting looks like this


and it will return the value stored for that key.

in this challenge we have an dictionary called languages with 2 key value pairs. the key for the first pair is "iOS" and the value is "Swift". this is the key value pair you need. we can get the value for the key "iOS" using

languages["iOS"] // returns "Swift"

so to retrieve the language used for iOS and then store it in a variable you would use

let languages = ["iOS": "Swift", "Android":"Java"]
var iosLanguage = languages["iOS"] // variable now has "Swift" as its value