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 2.0 Basics Swift Operators Working With Operators: Part 2

Valeria Ruiz
Valeria Ruiz
948 Points

operands and if then situations

hi guys, thanks so much for coming to help,

the instructions say declare a constant isWinner as the comparison equation which checks if the answer is 10 or anything but 10. if it is anything but then the player wins, if it is 10 they loose.

I think I need an if then statement, which I don't know how to do on Swift, also, we strictly have to use the operand "!". So I really don't know how to do it.

Please help

operators2.swift
// Enter your code below

var initialScore = 8
let totalScore = ++initialScore
initialScore != 10
let isWinner = initialScore

1 Answer

Hi Valeria,

You're kind of right; if the question was asking you to implement the whole game then you would definitely need if-then statements β€”Β among other things β€” to be successful. As it stands, it's just asking you to load the constant isWinner with an expression that evaluates to true or false in accordance with the given parameters. It should look like this:

var initialScore = 8
let totalScore = ++initialScore
let isWinner = totalScore != 10
Valeria Ruiz
Valeria Ruiz
948 Points

Thanks so much!! that helps out a lot!