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 Unary Operators

Edward Bromley
Edward Bromley
3,353 Points

Deprecation of ++ and --

It appears that Apple plans to remove these operators. https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md

Should the video reflect this?

Sebastian Nitu
Sebastian Nitu
8,616 Points

Yes, that is correct. Starting with Swift 2.2, the postfix operators ++ and -- will be depricated.

You can learn more about the upcoming Swift changes here: http://ericasadun.com/2015/12/03/changing-swift-whats-coming-up-in-2-2-and-3-0/

1 Answer

Michael Hulet
Michael Hulet
47,912 Points

The ++ and -- operators are deprecated in the latest version of Swift, and will be removed entirely in Swift 3.0, coming this Fall (assuming you live in the Northern Hemisphere. Otherwise, Spring). That being said, Swift is still a rapidly evolving language, and will continue to be as such for a long time, though a lot of stuff should be finalized with Swift 3, because that update will come with ABI stabilization. Because of that, my personal vote is towards adding teachers notes right now, and then recording new videos with Swift 3

Now that Swift 2.2 has been released, it would probably be good for the teacher's notes to be updated. It would be nice if the associated task were updated to support the alternative syntax as well.

Laura Ross
Laura Ross
Courses Plus Student 2,449 Points

I agree with Nathan. I can't figure out how += 1 is replacing ++. The auto-fixes suggested by the compiler are

x = ++b is now x = b += 1

and

x = b++ is now x = b += 1

Can someone explain the correct replacement?

Michael Hulet
Michael Hulet
47,912 Points

I wrote a far more detailed answer over here