Swift is removing the increment and decrement operators (++ and -- respectively). If this is news to you, hello from 2016! Bowie has left us, we have an iPad the size of a Prius, and Donald Trump is running for president.
But do you know why these operators are going away? The obvious answers are:
- Python did it
- Apple enjoys taking things away from you
- It’s old
- The Simpsons did it
for _ inis prettier
All very fun reasons but hardly substantive. The better arguments I’ve experienced is that
someVariable++ have different behavior but look visually similar. Add that to the fact that
+= is not a hefty burden to type and you could easily imagine the world without them.
Probably the best reason I’ve heard comes from the big man, Chris Lattner, himself:
“They encourage "overly tricky" code which may be cute, but difficult to understand.”
This is a wonderful rule of thumb if you’re ever left wondering why a feature goes to live on a farm upstate. Lattner goes on to give a great rule for determining what to throw out:
“if we didn't already have these, would we add them to Swift 3?”
You can read the arguments in their entirety here.