Xcode Beta 3 came out today, and with it a new version of the Swift standard library.

By far the majority of changes are to account for the publicized updates to the language:

replacing Type[] with [Type] , and making use of the new [Key:Val] sugar for dictionaries

with , and making use of the new sugar for dictionaries switching uncheckedArithOp for arithOpWithOverflow in all the numeric types

for in all the numeric types adding explicit bigEndian and littleEndian initializers to the integers

and initializers to the integers replacing succ and pred with successor and predecessor 1

and with and adding sorted as an operation on arrays and as a standalone algo, since sort now sorts in-place2

copy and unshare have been removed from Array, since they’re redundant now arrays have full value semantics. Assigning an array to another variable copies it. Or rather, it lazily copies it – the array will only by physically copied when you alter one of the elements. So really, the equivalent of unshare is called automatically when any value in the copied array or the copy is altered. You can still detect when this happens with the === operator, which returns true if two arrays are pointing to the same underlying store:

var a = [1, 2, 3, 4] let b = a // 'a' is "copied" // but really, it's still the same a === b // returns true a[2] = 2 // until you alter 'a' // and now they're different a === b // returns false

This is really important to understand, in case you start to panic about all the unnecessary copying that might happen when you pass an array into a function as a parameter.

There are also a handful of other changes/additions that aren’t mentioned in the release notes.

Range now supports map as a member, so you can write (1...5).map { $0 * 2 } much like with an Array , rather than map(1...5) { $0 * 2 } . Note, Range.map returns an Array , unlike the map algorithm, which returns a lazily-computed view class.

Lots more types (such as Range ) now have a getMirror() method.

min and max , which previously took two or more parameters (the “more” part being a variadic parameter) now have an overload with just two parameters. This means you can pass them as an argument to another function that expects a binary operator. So the following now compiles where previously it would throw an error:3

let a = [5, 3, 1, 7, 9] let b = [2, 4, 1, 1, 7] // now you can write this: let mins = map(Zip2(a, b), min) // instead of being forced to write this: let mins = map(Zip2(a, b)) { min($0, $1) }

Finally, the already mysterious insertionSort got a bit more mysterious.

Previously there were two versions, both of which required a collection with a bidirectional index. One just required that the collection contents be comparable. The other allowed the caller to supply a predicate to compare elements with. That’s a pretty standard pattern, but oddly that predicate is declared inout . Why a sort algorithm needs to be able to change the caller’s comparison function I do not know, but it can!4

The new insertionSort that doesn’t take a predicate now requires a random-access index, rather than a bidirectional index. The version that takes the predicate still only requires a bidirectional index. It’s predicate is still inout though.

There are a few other changes, relating to unicode character processing and Objective-C interfacing, that I either don’t feel qualified to comment on or haven’t delved into. Feel free to mention antyhing interesting about them in the comments.