[swift-users] Porting Swift 2.2 to Swift 3.0

Ryan Lovelett swift-dev at ryan.lovelett.me
Thu Jun 23 22:04:27 CDT 2016

The following code does not compile in Swift 3.0 and it used to compile
in Swift 2.2. I'm pretty sure it is a bug in Swift 3.0, since it used to
work in Swift 2.2, but perhaps it was a bug that it worked in Swift 2.2.


extension Dictionary {
    init<S: Sequence where S.Iterator.Element == Element>(pairs: S) {
        for (key, value) in pairs {
            self[key] = value

let foo = ["Lorem", "ipsum"]
let bar = ["dolor", "sit"]
let baz = zip(foo, bar)
let qux = baz.lazy
    .map({ ($0.uppercased(), $1.uppercased()) })

Dictionary(pairs: baz)
Dictionary(pairs: qux)

The before and after code can be seen in this gist.

More information about the swift-users mailing list