<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Mr Bee,</div><div class=""><br class=""></div><div class="">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:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(201, 27, 19);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> d1 = [</span><span style="font-variant-ligatures: no-common-ligatures" class="">"Apples"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">20</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span><span style="font-variant-ligatures: no-common-ligatures" class="">"Oranges"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">13</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">]</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(201, 27, 19);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> d2 = [</span><span style="font-variant-ligatures: no-common-ligatures" class="">"Oranges"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">3</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span><span style="font-variant-ligatures: no-common-ligatures" class="">"Cherries"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">9</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">]</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">Dictionary</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> merged(with another: [</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Key</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Value</span><span style="font-variant-ligatures: no-common-ligatures" class="">]) -> [</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Key</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Value</span><span style="font-variant-ligatures: no-common-ligatures" class="">] {</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> result = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">self</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">for</span><span style="font-variant-ligatures: no-common-ligatures" class=""> entry </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> another {</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> result[entry.key] = entry.value</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> result</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> result = </span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4" class="">d1</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #294c50" class="">merged</span><span style="font-variant-ligatures: no-common-ligatures" class="">(with: </span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4" class="">d2</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 11, 2016, at 12:05 AM, Mr Bee via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" class=""><div id="yui_3_16_0_ym19_1_1478850922588_9177" class=""><span class="">Hi,</span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" class=""><span class=""><br class=""></span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span id="yui_3_16_0_ym19_1_1478850922588_9300" class="">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 href="https://developer.apple.com/reference/foundation/nsmutabledictionary" class="">https://developer.apple.com/reference/foundation/nsmutabledictionary</a>). </span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span class=""><br class=""></span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span id="yui_3_16_0_ym19_1_1478850922588_9391" class="">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 href="https://developer.apple.com/reference/swift/dictionary" class="">https://developer.apple.com/reference/swift/dictionary</a>), no need to write a custom function, or bridging to NSMutableDictionary.</span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span class=""><br class=""></span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span class="">Thank you.</span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span class=""><br class=""></span></div><div id="yui_3_16_0_ym19_1_1478850922588_9177" dir="ltr" class=""><span class="">Regards,</span></div><div class="signature" id="yui_3_16_0_ym19_1_1478850922588_9174"><div id="yui_3_16_0_ym19_1_1478850922588_9175" class=""><br class=""></div>–Mr Bee<div id="yui_3_16_0_ym19_1_1478850922588_9301" class=""><br class=""></div></div></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>