<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_4215" dir="ltr"><span>> </span><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;" id="yui_3_16_0_ym19_1_1478858311546_4218">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.</span></div><div id="yui_3_16_0_ym19_1_1478858311546_4215" dir="ltr"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"><br></span></div><div></div><div id="yui_3_16_0_ym19_1_1478858311546_4098">Then how NSMutableDictionary.addEntries() solve this issue?</div><div id="yui_3_16_0_ym19_1_1478858311546_4098"><br></div><div id="yui_3_16_0_ym19_1_1478858311546_4098">I thought with Swift design, we could merge some compatible dictionaries simply by using + operator array. </div><div class="signature" id="yui_3_16_0_ym19_1_1478858311546_4262"><div id="yui_3_16_0_ym19_1_1478858311546_4261"><br></div>–Mr Bee<div id="yui_3_16_0_ym19_1_1478858311546_4263"><br></div></div> <div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1478858311546_4264"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1478858311546_4189" 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_4188"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1478858311546_4187"> <div dir="ltr" id="yui_3_16_0_ym19_1_1478858311546_4186"><font size="2" face="Arial" id="yui_3_16_0_ym19_1_1478858311546_4185"> Pada Jumat, 11 November 2016 15:14, Ray Fix <rayfix@gmail.com> menulis:<br></font></div> <br><br> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1478858311546_4192"><div id="yiv3292833272"><div id="yui_3_16_0_ym19_1_1478858311546_4191"><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4190">Hi Mr Bee,</div><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4193"><br clear="none" class="yiv3292833272"></div><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4194">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="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4207"><br clear="none" class="yiv3292833272"></div><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4197"><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(201, 27, 19);" id="yui_3_16_0_ym19_1_1478858311546_4206"><span class="yiv3292833272" style="color:#c32275;">let</span><span class="yiv3292833272" style="color:#000000;"> d1 = [</span><span class="yiv3292833272" style="">"Apples"</span><span class="yiv3292833272" style="color:#000000;">: </span><span class="yiv3292833272" style="color:#0435ff;">20</span><span class="yiv3292833272" style="color:#000000;">, </span><span class="yiv3292833272" style="">"Oranges"</span><span class="yiv3292833272" style="color:#000000;">: </span><span class="yiv3292833272" style="color:#0435ff;">13</span><span class="yiv3292833272" style="color:#000000;">]</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(201, 27, 19);" id="yui_3_16_0_ym19_1_1478858311546_4205"><span class="yiv3292833272" style="color:#c32275;">let</span><span class="yiv3292833272" style="color:#000000;"> d2 = [</span><span class="yiv3292833272" style="">"Oranges"</span><span class="yiv3292833272" style="color:#000000;">: </span><span class="yiv3292833272" style="color:#0435ff;">3</span><span class="yiv3292833272" style="color:#000000;">, </span><span class="yiv3292833272" style="">"Cherries"</span><span class="yiv3292833272" style="color:#000000;">: </span><span class="yiv3292833272" style="color:#0435ff;">9</span><span class="yiv3292833272" style="color:#000000;">]</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px;" id="yui_3_16_0_ym19_1_1478858311546_4204"><span class="yiv3292833272" style=""></span><br clear="none" class="yiv3292833272"></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(112, 61, 170);" id="yui_3_16_0_ym19_1_1478858311546_4200"><span class="yiv3292833272" style="color:#c32275;">extension</span><span class="yiv3292833272" style="color:#000000;"> </span><span class="yiv3292833272" style="">Dictionary</span><span class="yiv3292833272" style="color:#000000;"> {</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;" id="yui_3_16_0_ym19_1_1478858311546_4196"><span class="yiv3292833272" style=""> </span><span class="yiv3292833272" style="color:#c32275;">func</span><span class="yiv3292833272" style=""> merged(with another: [</span><span class="yiv3292833272" style="color:#703daa;">Key</span><span class="yiv3292833272" style="">: </span><span class="yiv3292833272" style="color:#703daa;" id="yui_3_16_0_ym19_1_1478858311546_4195">Value</span><span class="yiv3292833272" style="" id="yui_3_16_0_ym19_1_1478858311546_4198">]) -> [</span><span class="yiv3292833272" style="color:#703daa;">Key</span><span class="yiv3292833272" style="">: </span><span class="yiv3292833272" style="color:#703daa;">Value</span><span class="yiv3292833272" style="">] {</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;"><span class="yiv3292833272" style=""> </span><span class="yiv3292833272" style="color:#c32275;">var</span><span class="yiv3292833272" style=""> result = </span><span class="yiv3292833272" style="color:#c32275;">self</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;"><span class="yiv3292833272" style=""> </span><span class="yiv3292833272" style="color:#c32275;">for</span><span class="yiv3292833272" style=""> entry </span><span class="yiv3292833272" style="color:#c32275;">in</span><span class="yiv3292833272" style=""> another {</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;"><span class="yiv3292833272" style=""> result[entry.key] = entry.value</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;"><span class="yiv3292833272" style=""> }</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;"><span class="yiv3292833272" style=""> </span><span class="yiv3292833272" style="color:#c32275;">return</span><span class="yiv3292833272" style=""> result</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;" id="yui_3_16_0_ym19_1_1478858311546_4358"><span class="yiv3292833272" style=""> }</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;" id="yui_3_16_0_ym19_1_1478858311546_4359"><span class="yiv3292833272" style="">}</span></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px;"><span class="yiv3292833272" style=""></span><br clear="none" class="yiv3292833272"></div><div class="yiv3292833272" style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;" id="yui_3_16_0_ym19_1_1478858311546_4360"><span class="yiv3292833272" style="color:#c32275;">let</span><span class="yiv3292833272" style=""> result = </span><span class="yiv3292833272" style="color:#539aa4;">d1</span><span class="yiv3292833272" style="">.</span><span class="yiv3292833272" style="color:#294c50;">merged</span><span class="yiv3292833272" style="">(with: </span><span class="yiv3292833272" style="color:#539aa4;">d2</span><span class="yiv3292833272" style="">)</span></div></div><div class="yiv3292833272"><br clear="none" class="yiv3292833272"></div><br clear="none" class="yiv3292833272"><div id="yui_3_16_0_ym19_1_1478858311546_4363"><blockquote class="yiv3292833272" type="cite" id="yui_3_16_0_ym19_1_1478858311546_4362"><div class="yiv3292833272yqt9186751641" id="yiv3292833272yqt69991"><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4361">On Nov 11, 2016, at 12:05 AM, Mr Bee via swift-users <<a rel="nofollow" shape="rect" class="yiv3292833272" ymailto="mailto:swift-users@swift.org" target="_blank" href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:</div><br clear="none" class="yiv3292833272Apple-interchange-newline"><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4366"><div class="yiv3292833272" id="yui_3_16_0_ym19_1_1478858311546_4365"><div class="yiv3292833272" 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;" id="yui_3_16_0_ym19_1_1478858311546_4364"><div class="yiv3292833272" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272">Hi,</span></div><div class="yiv3292833272" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272"><br clear="none" class="yiv3292833272"></span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9300">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 rel="nofollow" shape="rect" class="yiv3292833272" target="_blank" href="https://developer.apple.com/reference/foundation/nsmutabledictionary">https://developer.apple.com/reference/foundation/nsmutabledictionary</a>). </span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272"><br clear="none" class="yiv3292833272"></span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9391">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 rel="nofollow" shape="rect" class="yiv3292833272" target="_blank" href="https://developer.apple.com/reference/swift/dictionary">https://developer.apple.com/reference/swift/dictionary</a>), no need to write a custom function, or bridging to NSMutableDictionary.</span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272"><br clear="none" class="yiv3292833272"></span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272">Thank you.</span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272"><br clear="none" class="yiv3292833272"></span></div><div class="yiv3292833272" dir="ltr" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9177"><span class="yiv3292833272">Regards,</span></div><div class="yiv3292833272signature" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9174"><div class="yiv3292833272" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9175"><br clear="none" class="yiv3292833272"></div>–Mr Bee<div class="yiv3292833272" id="yiv3292833272yui_3_16_0_ym19_1_1478850922588_9301"><br clear="none" class="yiv3292833272"></div></div></div></div>_______________________________________________<br clear="none" class="yiv3292833272">swift-users mailing list<br clear="none" class="yiv3292833272"><a rel="nofollow" shape="rect" class="yiv3292833272" ymailto="mailto:swift-users@swift.org" target="_blank" href="mailto:swift-users@swift.org">swift-users@swift.org</a><br clear="none" class="yiv3292833272">https://lists.swift.org/mailman/listinfo/swift-users<br clear="none" class="yiv3292833272"></div></div></blockquote></div><br clear="none" class="yiv3292833272"></div></div><br><br></div> </div> </div> </div></div></body></html>