[swift-evolution] Proposal: Add a sequence-based initializer to Dictionary
    Gregg Wonderly 
    greggwonderly at seqtechllc.com
       
    Fri Jan  5 11:55:35 CST 2018
    
    
  
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.  
Dictionary(allowDuplicate: true, pairs: [("z", 1), ("z", 2), ("z", 3), ("z", 4)]) so that the dictionary behavior remains in line with the compile time checks.
Gregg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180105/bf0c53cd/attachment.html>
    
    
More information about the swift-evolution
mailing list