[swift-users] Mapping a Dictionary to a Dictionary?
Jens Alfke
jens at mooseyard.com
Mon Aug 29 19:13:20 CDT 2016
> On Aug 29, 2016, at 4:38 PM, Zhao Xin <owenzx at gmail.com> wrote:
> ...
> _ = dict1.map {
I just use a `for` loop to iterate dict1, and inside it populate dict2. Using `map` here seems wasteful since it’s building an array that’s thrown away.
> dict2.updateValue(value, forKey:key)
This is a tangent, but: Why do you use this syntax instead of the more readable `dict2[key] = value`? (I assume they’re equivalent internally.)
—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160829/befa328f/attachment.html>
More information about the swift-users
mailing list