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 Swift 2.0 Basics Swift Operators Working With Operators: Part 2

I can't figure out why this solution is incorrect for part 2. let lose = totalScore == 10 let isWinner = !lose

I keep coming back to this challenge but I can't figure out what is wrong with this solution.

var initialScore = 8 let totalScore = ++initialScore let lose = totalScore == 10 let isWinner = !lose

1 Answer

andren
andren
28,558 Points

Your code technically works, but treehouse challenges are often pretty picky about the solution. Even if the result is right, if the method is not what the challenge expected it will sometimes fail you.

The problem is that task 2 can be solved without creating any variables other than isWinner, you don't actually need to create the lose variable, and doing so is confusing the challenge checking code since it it not expecting it.

The answer it expects looks like this:

var initialScore = 8
let totalScore = ++initialScore
let isWinner = !(initialScore == 10)