Welcome to the Treehouse Community
Looking to learn something new?
Alex Ferguson2,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"]
Stone Preston42,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