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 trial

iOS

unwrapping two optionals assigned to one if let statement

Hey,

So if i have some code as written below

func currentWeatherDictionaryfromjsonDictionary (jsonDictionary: [String: AnyObject]? ) -> CurrentWeather? { if let currentWeatherama = jsonDictionary?["currently"] as? [String: AnyObject] {...

Now there are two optionals in the if let statement, the first is jsonDictionary? and the second is the optional returned from accessing the dictionary which is casted to an optional(since the key might not exist)

the question is which optional does this if let statement unwrap, or is it both?

I thought it would have been to unwrap only the second optional but when i played around in the playground it seemed like jsonDictionary was unwrapped as well.