[swift-users] Mapping a Dictionary to a Dictionary?

Zhao Xin owenzx at gmail.com
Mon Aug 29 16:07:29 CDT 2016


I don''t quite understand your question. In Swift, Dictionaries are
structs. You can always use `let dict2 = dict1`. That is enough. Or did you
mean below code?

var dict1 = ...
var dict2 = ...
for (key, value) in dic1 {
    dic2.updateValue(value, forKey:key)
}

Zhaoxin

On Tue, Aug 30, 2016 at 4:36 AM, Jens Alfke via swift-users <
swift-users at swift.org> wrote:

> I may be missing something obvious, but I can’t find a library function
> that maps a Dictionary to another Dictionary, transforming the keys and/or
> values. The only method I’ve found is the regular map(), which results in
> an Array. Does this just not exist in the standard library?
>
> —Jens
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160830/d0fc8fd7/attachment.html>


More information about the swift-users mailing list