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 trialAlex Kissi
14,202 PointsSwift 1.2 as! for failable casts — Casts that can fail at runtime are now expressed with the new as! operator to make th
Swift 1.2 as! for failable casts — Casts that can fail at runtime are now expressed with the new as! operator to make their potential for runtime failure clear to readers and maintainers of your code.
so to prevent syntax error please change all the "as" downcast to "as!" adding a Bang operator to the end of the " as"
3 Answers
Alex Kissi
14,202 PointsSo adding a bang operator at the end of the "as" helps? Or it doesn't matter based on the Xcode versions.
Brice Amram
2,937 PointsWell it sure helped for me. I don't where to check the version of Swift I'm using although I'm almost sure it's Swift 1.2 (with Xcode 6.3).
I thought your initial comment was already an answer + the explanation of why you need to add a bang operator in the most recent version of Swift. Or maybe I'm just confused now?
Alex Kissi
14,202 PointsIt was shift 1.2 that made that update. Either way adding a bang helped. Thank you for your feedback
Brice Amram
2,937 PointsBrice Amram
2,937 PointsThanks Alex for clarifying that. It did seem to have something to do with different versions of Swift or Xcode (different behaviors betw. live Xcode and Pasan's video), but things that go without saying are better said : ) Small confusion cleared.