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 Rassoli
3,365 PointsSoftware Issues? Perhaps
I copy the same code as the video into my current version of swift and get an error. I think this video was recorded with Swift 3 and my version is Swift 4. Doesn't anyone have a solution? Code is written below.
for number in 1...10 { print("times 5 is equal to") }
error given: Immutable value 'number' was never used; consider replacing with '_' or removing it.
1 Answer
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Ryan,
You are not getting an error, you are getting a warning (the yellow triangle). The difference is that a warning is triggered when the code is syntactically valid (the code compiles), but the compiler notices that something is probably not the way you want. In this case, it's letting you know that you've gone to the trouble of declaring a constant name but you never used it.
This is different from an error (the red symbol) which indicates that your code won't compile at all.
I'm guessing that for the purposes of the video, Pasan has told his version of Xcode to not show warnings (in Xcode/Preferences/General uncheck 'Show live issues').
Hope that clears everything up,
Cheers
Alex