This is the part where some people will start to drift off in confusion, which is a shame because it's important.
Here's are some quotes from the Swift API guidelines:
Got that? It's no surprise that Swift's rules are expressed using lingustic terminology – it is after all a language! – but this at least gives me a chance to feel smug that I did a second degree in English. What it means is that many methods are changing names in subtle and sometimes confusing ways.
Let's start with a couple of simple examples:
myArray.enumerate()
myArray.enumerated()
myArray.reverse()
myArray.reversed()
Each time Swift 3 modifies the method by adding a "d" to the end: this is a value that's being returned.
These rules are mostly innocent enough, but it causes confusion when it comes to array sorting. Swift 2.2 used sort()
to return a sorted array, and sortInPlace()
to sort an array in place. In Swift 3.0, sort()
is renamed to sorted()
(following the examples above), and sortInPlace()
is renamed to sort()
.
TL;DR: This means you need to be careful because in Swift 2.2 sort()
returned a sorted array, but in Swift 3.0 sort()
sorts the array in place.
SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Download all Swift 3.0 changes as a playground Link to Swift 3.0 changes
Link copied to your pasteboard.