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

Tim Seme
Tim Seme
1,664 Points

totalScore = ++initialScore

it won't let me through even though I'm doing as i was taught

operators2.swift
// Enter your code below

var initialScore = 8
initialScore = initialScore + 1

let totalScore = initialScore
totalScore = ++initialScore

3 Answers

Ronnie Stanley
Ronnie Stanley
4,842 Points

if you run your code in an xcode playground the compiler will help you with the fix. the constant totalScore needs to be a variable

var initialScore = 8
initialScore = initialScore + 1

var totalScore = initialScore
totalScore = ++initialScore
Tim Seme
Tim Seme
1,664 Points

ok i know that and this way it works in Xcode but its telling me to make totalScore a constant and then change it, even though constant can't be changed

Ronnie Stanley
Ronnie Stanley
4,842 Points

Sorry, here is the answer you're looking for

var initialScore = 8


let totalScore = ++initialScore