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

comparison operation

I stuck in comparison operation. Not sure what to do, Google says that I can use if statement, however it does not work still.... How to compare operations using NOT operator?

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1

2 Answers

You can use the operator like this -

var initialScore = 8
initialScore += 1

let isWinner = initialScore != 10

The above line evaluates whether the initialScore is not equal to 10 and then stores the result in the isWinner constant. Since 9 is not equal to 10, hence the expression evaluates to true. Hope this helps :)

ouchh, so easy. I tried so many commands, I googled for possible commands more than 1 hour.. Thank you

You're welcome :)