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

I'm having trouble with the last challenge in swift basics using the NOT operator.

I'm trying to pass the last swift basics challenge when i put in my code I get the error that my int can not be a bool value I have tried several different combinations of code but nothing seems to compute

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1
let loose = 10
let isWinner = !10

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

HI Emilia,

You've got the first part correct :thumbsup: and the error you're getting for the second part isn't very explanatory, so lets have a closer look.

First, the instructions didn't say anything about creating a variable named loose, so you've got to delete that line. Instructions will always be very specific and always need to be followed exactly. If you add something that wasn't asked for, a Bummer! will follow.

Next, you're more or less on the right track with the isWinner, it's just missing a little step. You need to compare the value being stored in the initialScore to the value of 10, and then return and assign that to the variable isWinner.
Right now, the code is trying to assign !10 to the variable. There is no comparison. So, to compare, you'd need the variable being compared and the value being compared to like this: initialScore != 10. This will return a boolean based on the comparison. Next, it needs to be assigned to the isWinner variable...

let isWinner = initialScore != 10

Keep Coding! :) :dizzy:

Thanks Jason I think I did that before but I was putting my ! Before the ten not the =. your explanation really helped to sink it in. Thanks for the help :)