++ and -- are deprecated
About 2 min
++ and -- are deprecated 관련
HACKING WITH SWIFT
What's new in Swift?
++ and -- are deprecated | Changes in Swift 2.22.2
++ and -- are deprecated
Available from Swift 2.2
Swift 2.2 formally deprecates the ++
and --
operators, which means they still work but you'll get a warning when you use them. Deprecation is usually a first step towards removing something entirely, and in this case both of these operators will be removed in Swift 3.0.
In their place, you need to use += 1
and -= 1
instead. These operators have been there all along, and are not going away.
You might wonder why two long-standing operators are being removed, particularly when they exist in C, C#, Java, and – critically to its "joke" – C++. There are several answers, not least:
- Writing
++
rather than+= 1
is hardly a dramatic time saving - Although it's easy once you know it,
++
doesn't have an obvious meaning to people learning Swift, whereas+=
at least reads as "add and assign." - C-style loops – one of the most common situations where
++
and--
were used – have also been deprecated, which brings me on to my next point…
Other changes in Swift 2.2…
Traditional C-style for loops are deprecated | Changes in Swift 2.2
Traditional C-style for loops are deprecated
Comparing tuples | Changes in Swift 2.2
Comparing tuples
Tuple splat syntax is deprecated | Changes in Swift 2.2
Tuple splat syntax is deprecated
More keywords can be used as argument labels | Changes in Swift 2.2
More keywords can be used as argument labels
Variable parameters have been deprecated | Changes in Swift 2.2
Variable parameters have been deprecated
Renamed debug identifiers: line, function, file | Changes in Swift 2.2
Renamed debug identifiers: line, function, file
Stringified selectors are deprecated | Changes in Swift 2.2
Stringified selectors are deprecated
Compile-time Swift version checking | Changes in Swift 2.2
Compile-time Swift version checking