<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Okay, that does work for my example. But why wouldn’t the key also be available so that you might be able to have selective handling of first vs last for each key?<div class=""><br class=""></div><div class="">Gregg<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 4:03 PM, Nate Cook <<a href="mailto:natecook@apple.com" class="">natecook@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Gregg —<div class=""><br class=""></div><div class="">The Dictionary(_:uniquingKeysWith:) initializer was added for this purpose in Swift 4—please see <a href="https://developer.apple.com/documentation/swift/dictionary/2892961-init" class="">https://developer.apple.com/documentation/swift/dictionary/2892961-init</a><br class=""><div class=""><br class=""></div><div class="">Nate</div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 1:02 PM, Gregg Wonderly via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">In some dictionary implementations, key-value pairs are added with an add() method which disallows duplicate keys to be inserted with a runtime exception. Providing an additional method of set() allows for the ability to ignore duplicate keys so that it feels more like dict[key] = value. It might be interesting to provide this as a selectable behavior within an additional constructor's arguments. <div class=""><br class=""></div><div class="">Dictionary(allowDuplicate: true, pairs: <span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">[("z", 1), ("z", 2), ("z", 3), ("z", 4)]) so that the dictionary behavior remains in line with the compile time checks.</span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">Gregg</span></span></div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>