3 ms·
Why remove x++ and not x += 1? Demand X = X + 1. For clarity/readability/formatting.
by nevereverreg 11y ago
Why remove x++ and not x += 1?
Demand X = X + 1. For clarity/readability/formatting.
- dragonwriter 11y ago> Why remove x++ and not x += 1? A key part of the reason for removing the ++/-- set of operators seems to be that they conflict with Swift's pattern of mutating operators returning void. (An alternative offered was revising them so that they followed that pattern.) +=/-=, like simple assignment, do not have that problem.
- vvpan 11y agoWell, I assume that it's because myObject.someVariable = myObject.someVariable + 1 is harder to read than myObject.someVariable += 1 Also it's annoying to type and increases the chance of typos.