Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Collections and Control Flow Control Flow With Loops Looping Over Ranges

Ryan Rassoli
Ryan Rassoli
3,365 Points

Software 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
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,862 Points

Hi 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