<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1478858311546_9057" dir="ltr"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;" id="yui_3_16_0_ym19_1_1478858311546_9087">> SE-0100 Add sequence-based initializers and merge methods to Dictionary</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;" id="yui_3_16_0_ym19_1_1478858311546_9088"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;" id="yui_3_16_0_ym19_1_1478858311546_9089"> </span><a shape="rect" href="https://github.com/apple/swift-evolution/blob/master/proposals/0100-add-sequence-based-init-and-merge-to-dictionary.md" target="_blank" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;" id="yui_3_16_0_ym19_1_1478858311546_9090">https://github.com/apple/swift-evolution/blob/master/proposals/0100-add-sequence-based-init-and-merge-to-dictionary.md</a><span><br></span></div><div id="yui_3_16_0_ym19_1_1478858311546_9057"><span><br></span></div><div id="yui_3_16_0_ym19_1_1478858311546_9057"><span id="yui_3_16_0_ym19_1_1478858311546_9056">Thank you for the information. It looks like a good proposal.</span></div><div></div><div id="yui_3_16_0_ym19_1_1478858311546_9120"> </div><div class="signature" id="yui_3_16_0_ym19_1_1478858311546_8978"><div id="yui_3_16_0_ym19_1_1478858311546_9121"><br></div>–Mr Bee<div id="yui_3_16_0_ym19_1_1478858311546_8980"><br></div></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1478858311546_9046" style="display: block;"> <div style="font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1478858311546_9045"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1478858311546_9044"> <div dir="ltr" id="yui_3_16_0_ym19_1_1478858311546_9043"><font size="2" face="Arial" id="yui_3_16_0_ym19_1_1478858311546_9042"> Pada Jumat, 11 November 2016 15:50, Martin R <martinr448@gmail.com> menulis:<br></font></div> <br><br> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1478858311546_9047">Nate Cook proposed merging dictionary initializers (with optional conflict resolution) to be added to the standard library:<br clear="none"><br clear="none"> SE-0100 Add sequence-based initializers and merge methods to Dictionary<br clear="none"> <a shape="rect" href="https://github.com/apple/swift-evolution/blob/master/proposals/0100-add-sequence-based-init-and-merge-to-dictionary.md" target="_blank" id="yui_3_16_0_ym19_1_1478858311546_9048">https://github.com/apple/swift-evolution/blob/master/proposals/0100-add-sequence-based-init-and-merge-to-dictionary.md</a><br clear="none"><br clear="none">Martin<br clear="none"><br clear="none"><br clear="none">> On 11 Nov 2016, at 09:14, Ray Fix via swift-users <<a shape="rect" ymailto="mailto:swift-users@swift.org" href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br clear="none">> <br clear="none">> Hi Mr Bee,<br clear="none">> <br clear="none">> The reason I don’t think it is provided is because it is difficult to know what to do when keys collide. You could easily write such a thing and decide your own policy. For example:<br clear="none">> <br clear="none">> let d1 = ["Apples": 20, "Oranges": 13]<br clear="none">> let d2 = ["Oranges": 3, "Cherries": 9]<br clear="none">> <br clear="none">> extension Dictionary {<br clear="none">> func merged(with another: [Key: Value]) -> [Key: Value] {<br clear="none">> var result = self<br clear="none">> for entry in another {<br clear="none">> result[entry.key] = entry.value<br clear="none">> }<br clear="none">> return result<br clear="none">> }<br clear="none">> }<br clear="none">> <br clear="none">> let result = d1.merged(with: d2)<br clear="none">> <br clear="none">> <br clear="none">>> On Nov 11, 2016, at 12:05 AM, Mr Bee via swift-users <<a shape="rect" ymailto="mailto:swift-users@swift.org" href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br clear="none">>> <br clear="none">>> Hi,<br clear="none">>> <br clear="none">>> I'm using Swift v3 on an El Capitan machine. I want to merge a dictionary into another compatible dictionary. However, I couldn't find addEntries function in the dictionary instance, like it was on NSMutableDictionary (<a shape="rect" href="https://developer.apple.com/reference/foundation/nsmutabledictionary" target="_blank">https://developer.apple.com/reference/foundation/nsmutabledictionary</a>). <br clear="none">>> <br clear="none">>> Does that mean that Swift standard library won't provide such similar function for native Swift dictionary? Or is there any other way of doing that natively? I mean using the built-in Swift's native dictionary function (<a shape="rect" href="https://developer.apple.com/reference/swift/dictionary" target="_blank">https://developer.apple.com/reference/swift/dictionary</a>), no need to write a custom function, or bridging to NSMutableDictionary.<br clear="none">>> <br clear="none">>> Thank you.<br clear="none">>> <br clear="none">>> Regards,<br clear="none">>> <br clear="none">>> –Mr Bee<br clear="none">>> <br clear="none">>> _______________________________________________<br clear="none">>> swift-users mailing list<br clear="none">>> <a shape="rect" ymailto="mailto:swift-users@swift.org" href="mailto:swift-users@swift.org">swift-users@swift.org</a><br clear="none">>> <a shape="rect" href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><div class="yqt3154208410" id="yqtfd66134"><br clear="none">> <br clear="none">> _______________________________________________<br clear="none">> swift-users mailing list<br clear="none">> <a shape="rect" ymailto="mailto:swift-users@swift.org" href="mailto:swift-users@swift.org">swift-users@swift.org</a><br clear="none">> <a shape="rect" href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br clear="none"></div><br><br></div> </div> </div> </div></div></body></html>