iOS Swift Basics Swift Operators Working With Operators: Part 2

Christian Ollivares
PRO
Christian Ollivares
Pro Student 194 Points

Is this a unary operation? It is confusing trying to write this in one line of code.

Don't know how to assign the value and compare at the same time.

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1 


let isWinner = true 

2 Answers

kjvswift93
kjvswift93
13,433 Points

The value you are assigning to the isWinner constant is going to be a boolean value, in this case the comparison of initialScore and the number 10 - specifically whether or not the value of initialScore is NOT equal to 10. So, on the other side of the equal sign, you should write the equivalent of "The value of initialScore is not equal to 10".

let isWinner = "The value of *initialScore* is not equal to 10" 
Christian Ollivares
Christian Ollivares
Pro Student 194 Points

Thank you ! I was unaware that I could use initialScore. I was trying to do this with isWinner constant byitself.

Steven Parker
Steven Parker
176,634 Points

You've already done task 1, which used the unary operator.

For task 2, any comparison expression (made of two terms with a comparison operator between them) produces a value, and that value can then be assigned to a variable. For example:

let isBiggerThan5 = myValue > 5