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!

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 am stuck...I am not sure how to set this up.

I am not sure how to set this up. If you answer please provide the reasoning behind how and why it needs to be a curtain way..Thank you!

// Enter your code below

var initialScore = 8
let totalScore = ++initialScore 
let isWinner  = true
if isWinner !10 {
print("he or she has lost")

3 Answers

Hey Rose,

First of all, please use the search bar before asking, a lot of students already asked the same. You can see here : https://teamtreehouse.com/community/code-challenge:9442

Regarding your code,

if isWinner !10

is not correct, even if it's not what they ask. You shloud have written

if isWinner != 10

BUT as you defined isWinner as a Boolean, this comparison will be always true.

So they ask to assign the comparison to a constant isWinner (which will be a boolean), your beginning is correct.

let isWinner =

What is the comparison ? We have to check if totalScore is or is not equal to then. If it's not, isWinner is true. Or as we want to win, we want isWinner true, so we want totalScore different of 10. Let's write the comparison

totalScore != 10

This line return "true", try in a playground. So as isWinner will be a boolean, we can assign this comparison to isWinner like this

let isWinner = (totalScore!= 10)

Thank you for your help! And the info of using the search bar.

You're welcome, don't forget to choose my answer to show that your problem is solved !