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 trialTrent Porter
611 Points++ operation being removed in Swift 3.
During this lesson, it says to use ++ to increase the value of something by 1. But Swift notified me it is being removed in Swift 3, which would result in this portion of the video needing to be changed upon release of Swift 3.
3 Answers
Adam Mazurick
Courses Plus Student 7,653 PointsApple has removed the ++ and made it much simpler with the another old traditional way.
Instead of ++, you need to write +=.
Example:
var x = 1
//Increment
x += 1 //Means x = x + 1 Similarly for decrement operator --, you need to write -=
Andrew Doumith
1,392 PointsCan you please shed some light about why in the world Apple decided to do this? How does simply changing ++ to += make it simpler?
Andrew Doumith
1,392 PointsActually... XCode says that += is not a valid prefix unary operator.
ㅤ ㅤ
2,370 Pointsㅤ ㅤ
2,370 Pointsyes that's correct. You can see some upcoming changes here: http://ericasadun.com/2015/12/03/changing-swift-whats-coming-up-in-2-2-and-3-0/ I think it's best to ignore any depreciation messages for now.