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 trialdwi asri
3,187 PointsExpected type after 'as'
Expected type after 'as'
I have problem when following the code in video: temperature = weatherDictionary["temperature"] as! Int
I already do same step by step just like the video but at mine an error show up.
1 Answer
Ben Myhre
28,726 PointsI find it interesting that it was indicated that this has all been gone through before, but
temperature = weatherDictionary["temperature"] as! Int
does not work for me because of my version... and I have not encountered the as with a bang before. That particular thing has not been covered before and would be worthy of a versioning note, IMO.
Andre Kovac
5,588 PointsI second that! Before something like
temperature = weatherDictionary["temperature"] as Int!
was discussed. But, not as!
.
Gwinyai Nyatsoka
7,428 PointsGwinyai Nyatsoka
7,428 PointsThe 'as!' notation was not introduced until Xcode 6.3. Lower Xcode versions do not understand 'as!' that is the cause of the compiler error you are getting. You will have to use simple 'as' if your Xcode version is a lower than Xcode 6.3.