The definition of the keys and values properties is preceded by the following: comments:
/// A collection containing just the keys of `self` /// /// Keys appear in the same order as they occur as the `.0` member /// of key-value pairs in `self`. Each key in the result has a /// unique value. var keys: LazyBidirectionalCollection<MapCollectionView<[Key : Value], Key>> { get } /// A collection containing just the values of `self` /// /// Values appear in the same order as they occur as the `.1` member /// of key-value pairs in `self`. var values: LazyBidirectionalCollection<MapCollectionView<[Key : Value], Value>> { get }
My interpretation
Keys / Values ββare displayed in the same order that they occur as a member of a .0 / .1 key-value pair in self .
it is that dictionary.keys and dictionary.values return the keys and values ββin an βappropriateβ order.
Thus, the key-value pairs of the dictionary do not have a specific order, but the first, second, ... dictionary.values element is the dictionary.values value corresponding to the first, second, ... dictionary.keys element.
source share