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 Unary Operators

williambengtsson2
williambengtsson2
1,103 Points

Can't solve second task...

I don't understand the second task.

First task solved:

var initialScore = 8
initialScore += 1

But the second... I've tried so many things, I don't understand the question, I'm getting something to 10 somehow?

let isWinner = true
let isWinner = !isWinner

8 Answers

andren
andren
28,520 Points

A big hint for this task is that you can directly assign the result of a comparison to a variable. Like this:

let example = 3 == 2 // equals operator
// example ends up storing the Boolean "false" since 3 is not equal to 2.

let example2 = 3 != 2 // not equals operator
// example2 ends up storing the Boolean "true" since 3 is not equal to 2.

With that knowledge you should be able to figure out the answer to the challenge.

williambengtsson2
williambengtsson2
1,103 Points

Thank you, that solved it. Didn't know about that, very nice of you and to answer so quick as well. Cheers!

let isWinner = intitalScore != 10

Thanks all guys for your thoughts!

Anna Brown
Anna Brown
6,353 Points

I still can't get it. I guess I need to watch the video again.

Lloyd David
Lloyd David
1,424 Points

Answer

let isWinner = 10 == 10

I found success with :

let isWinner = 9 != 10

let isWinner = initialSore != 10