"'++' is deprecated: it will be removed in swift 3 " Code Answer

4

since swift 2.2, you should use += 1 or -= 1 instead.

and after looking up swift's evolution, there are some reasons for removing these operators:

  1. these operators increase the burden to learn swift as a first programming language - or any other case where you don't already know these operators from a different language.

  2. their expressive advantage is minimal - x++ is not much shorter than x += 1.

  3. 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.

  4. 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.

  5. code that actually uses the result value of these operators is often confusing and subtle to a reader/maintainer of code. they encourage "overly tricky" code which may be cute, but difficult to understand.

  6. 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.

  7. 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.

finally, these fail the metric of "if we didn't already have these, would we add them to swift 3?"

please check out swift evolution for more info.

By user1307434 on February 26 2022

Answers related to “'++' is deprecated: it will be removed in swift 3 ”

Only authorized users can answer the Search term. Please sign in first, or register a free account.