[swift-evolution] map-like operation that returns a dictionary
Developer
devteam.codafi at gmail.com
Wed Jan 13 10:29:16 CST 2016
When we drew these up in Swiftz we called them `mapAssociate` and `mapAssociateLabel` after the combinators "associate" and "label" in other languages
https://github.com/typelift/Swiftz/blob/master/Swiftz/ArrayExt.swift#L491-L504
~Robert Widmann
2016/01/13 11:13、Kenny Leung via swift-evolution <swift-evolution at swift.org> のメッセージ:
> This solution looks great! How do you feel about “mapDict”?
>
> -Kenny
>
>
>>> On Jan 12, 2016, at 10:28 AM, Craig Cruden <ccruden at novafore.com> wrote:
>>>
>>>
>>>
>>> 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.
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list