Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRyan Forte
iOS Development Techdegree Student 2,955 Pointsoptional binding not working
// optioinal binding
let weatherDictionary: [String : [String : String]] = [
"currently": ["temperature": "22.3"],
"daily": ["temperature": "22.3"],
"weekly": ["temperature": "22.3"]
]
if let dailyWeather = weatherDictionary["daily"], let highTemperature = dailyWeather["temperature"] {
print(highTemperature)
}
i get these errors come up: 4- expected decleration
- variable used within its own intitial value
note: i have the latest version of xcode
Greg Kaleka
39,021 PointsCopy/pasted your code and it worked fine for me as well.
Drew Carver
5,189 PointsDrew Carver
5,189 PointsI tried to reproduce this, and I don't see any errors in the code. What line are you getting that error on?