[swift-evolution] map-like operation that returns a dictionary

Craig Cruden ccruden at novafore.com
Tue Jan 12 12:28:26 CST 2016

> I named the method(s) „toDict“ instead of „map“ because map normally returns a collection which is either the same as the receiver or a simple one.
> The second version is more general and allows to do things like
> let dict = ["Tom", "Dick", "Harry"].enumerate().toDict { (index, value) in (index + 1, value) }

Map would probably be a more correct mathematically speaking — but it would be inconsistent with the naming convention already chosen for Swift.  So for Swift - toDict (or toDictionary) would be the best choice.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160113/de61d75e/attachment.html>

More information about the swift-evolution mailing list