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

Mohammed Abdulwahab
Mohammed Abdulwahab
1,477 Points

How could this be wrong !

var initialScore = 8

initialScore = initialScore + 1

let totalScore = initialScore

operators2.swift
// Enter your code below

var initialScore = 8

initialScore = initialScore + 1

let totalScore = initialScore

3 Answers

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

The want you to do the totalscore & increment in 1 statement:

var initialScore = 8

let totalScore = ++initialScore

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Cindy Lea is correct. Your code is functional but you missed this line in the instructions "let's add 1 point to their score using the increment operator". You must use the increment operator for this challenge. It's important to note though that as of Xcode 7.3 the increment operator will be deprecated, so don't get too used to using it in Swift.

:information_source: Code challenge specifications should be followed to the letter. Any deviation can cause the challenge to fail even if your code is functional outside the challenge. Happy coding! :smiley: