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

Edwin Brown
PLUS
Edwin Brown
Courses Plus Student 1,787 Points

Need help with code

I may not understand the output of the question

operators2.swift
// Enter your code below

var initialScore = 8
let totalScore = ++initialScore 
//let isWinner = totalScore
var player = totalScore
let isWinner = true
let isLoser = !isWinner

2 Answers

Jari Koopman
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jari Koopman
Python Web Development Techdegree Graduate 29,349 Points

Hi Edwin,

You don't need the isLoser part of the code. This works just fine:

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

Hope this helped,

Kind regards, Jari

Simon Coates
Simon Coates
28,694 Points

I'm not familiar with swift, and i'm not sure what the issue is, but the following code passed:

var initialScore = 8
let totalScore = ++initialScore 
//let isWinner = totalScore
var player = totalScore
let isWinner = totalScore != 10
let isLoser = !isWinner

Uncertain if that helps you.