0

Removed in Swift 3

In new Swift version, this is removed feature. You can't use ++. It says: '++' is unavailable: it has been removed in Swift 3. But, you can replace it with += 1 instead.

28th Jan 2017, 6:59 PM
Nemanja MadĆŸa
Nemanja MadĆŸa - avatar
1 Answer
0
There are some reasons for removing this operator: 1- Their expressive advantage is minimal x++ is not much shorter than x += 1. 2- Swift already deviates from C in that the =, += and other assignment-like operations returns Void (for a number of reasons). These operators are inconsistent with that model. 3- Swift has powerful features that eliminate many of the common reasons you'd use ++i in a C-style for loop in other languages, so these are relatively infrequently used in well-written Swift code. These features include the for-in loop, ranges, enumerate, map, etc. 4- Code that actually uses the result value of these operators is often confusing. 5-While Swift has well defined order of evaluation, any code that depended on it (like foo(++a, a++)) would be undesirable even if it was well-defined. 6- These operators are applicable to relatively few types: integer and floating point scalars, and iterator-like concepts. They do not apply to complex numbers, matrices, etc.
14th Feb 2017, 11:46 AM
Felipe Cruz
Felipe Cruz - avatar