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 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
231,268 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