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 trialShiv Bhatia
1,760 PointsI'm using Swift 2.0, and when I try to use the NOT operator (!) it tells me that it's not a recognised operator.
Is this an update? If so, what is the right operator?
2 Answers
ianhan3
4,263 Points"!" is definitely still an operator. In what context are you using it? If you try something like
cat != dog
in your playground, the results panel will show true.
Shiv Bhatia
1,760 PointsI was using an 'if else' statement to check if a number was divisible by 3 and not 5, 5 and not 3, and then 3 and 5. It was the FizzBuzz generator from Swift Basics, and it looked like this:
if num % 3 == 0 && ! num % 5 == 0 { //Fizz } else if ! num % 3 == 0 && num % 5 == 0 { //Buzz } else if num % 3 == 0 && num % 5 == 0 { //FizzBuzz } else { //Print num }
It kept showing me an error saying '!' was not a valid binary operator, or that it 'expected a { after if condition.'