New in Swift Beta 3

7 thoughts
last posted July 12, 2014, 4:05 p.m.
0
get stream as: markdown or atom
0

Instead of Foo[] the syntactic sugar for Array<Foo> is now [Foo].

0

[Key:Value] has now been introduced as syntactic sugar for Dictionary<Key, Value>

0

The half-closed operator .. is now ..<.

... has stayed the same.

0

The global sort function now mutates its first argument.

A new sorted function returns a new collection.

0

pi (and presumably maths functions) are no longer available via import Foundation. Not yet sure where they've moved.

UPDATE: I can just use M_PI.

0

This fails in Beta 3:

 struct Foo {}

struct Bar { var data: [Foo] init() { data = Foo } func test() { data[2] = Foo() } } 

with

error: '@lvalue $T7' is not identical to 'Foo' at the data[2] = Foo() line. Just to be clear, the following works in the initial release: struct Foo {} struct Bar { var data: Foo[] init() { data = Foo[](count: 5, repeatedValue: Foo()) } func test() { data[2] = Foo() } } UPDATE: The failure is not because Foo is empty. The following fails: struct Foo { let i: Int } struct Bar { var data: [Foo] init() { data = [Foo](count: 5, repeatedValue: Foo(i:2)) } func test() { data[2] = Foo(i:2) } } with error: '@lvalue$T8' is not identical to 'Foo'

UPDATE 2: changing Bar to a class fixes the issue. Hat tip to Andy Dirnberger for the suggestion.