[swift-users] Porting Swift 2.2 to Swift 3.0
Ryan Lovelett
swift-dev at ryan.lovelett.me
Thu Jun 23 22:35:24 CDT 2016
On Thu, Jun 23, 2016, at 11:18 PM, Erica Sadun wrote:
>
>> On Jun 23, 2016, at 9:04 PM, Ryan Lovelett via swift-users <swift-
>> users at swift.org> wrote:
>>
>> extension Dictionary {
>> init<S: Sequence where S.Iterator.Element == Element>(pairs: S) {
>> self.init()
>> 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)
>
>
> extension Dictionary {
> init<S: Sequence where S.Iterator.Element == (Key,
> Value)>(pairs: S) {
> self.init()
> 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()) })
>
> print(Dictionary(pairs: baz))
> print(Dictionary(pairs: qux))
>
> -- E
>
Thank you 🙏
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160623/a713eb36/attachment.html>
More information about the swift-users
mailing list