Swift Dictionaries should document order for keys / values

Originator:subdigital
Number:rdar://17223678 Date Originated:08-Jun-2014 10:50 AM
Status:Open Resolved:
Product:Documentation Product Version:Swift Dictionary keys/values ordering
Classification:Other Bug Reproducible:Not Applicable
 
Summary:
a swift Dictionary has a .keys and .values properties which return arrays. The docs do not say whether or not there is a guarantee that the order will be preserved for these two.

In my testing, the order *is* the same (which is the behavior I prefer) however the docs should reflect this guarantee, otherwise we won’t be able to depend on it.

Example:

let dict = [ “drink”: “lagunitas”, “appetizer”: “quail eggs”, “entree”: “pork chop”  ]

dict.keys    //  returns [“appetizer”, “drink”, “entree”]
dict.values //  returns [“quail eggs”, “lagunitas”, “pork chop”]

(The actual order doesn’t matter, as long as the same order is guaranteed for both)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!