A collection containing just the values of the dictionary.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
var values: Dictionary<Key, Value>.Values { get set }
Discussion
When iterated over, values appear in this collection in the same order as they occur in the dictionary’s key-value pairs.
let countryCodes = ["BR": "Brazil", "GH": "Ghana", "JP": "Japan"]
print(countryCodes)
// Prints "["BR": "Brazil", "JP": "Japan", "GH": "Ghana"]"
for v in countryCodes.values {
print(v)
}
// Prints "Brazil"
// Prints "Japan"
// Prints "Ghana"