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

Is this a unary operation? It is confusing trying to write this in one line of code.

Don't know how to assign the value and compare at the same time.

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1 


let isWinner = true 

2 Answers

The value you are assigning to the isWinner constant is going to be a boolean value, in this case the comparison of initialScore and the number 10 - specifically whether or not the value of initialScore is NOT equal to 10. So, on the other side of the equal sign, you should write the equivalent of "The value of initialScore is not equal to 10".

let isWinner = "The value of *initialScore* is not equal to 10" 

Thank you ! I was unaware that I could use initialScore. I was trying to do this with isWinner constant byitself.

Steven Parker
Steven Parker
210,423 Points

You've already done task 1, which used the unary operator.

For task 2, any comparison expression (made of two terms with a comparison operator between them) produces a value, and that value can then be assigned to a variable. For example:

let isBiggerThan5 = myValue > 5