Dictionary
class Dictionary
A heterogeneous dictionary which stores associations between keys of the different types and values of the different types in a collection with no defined ordering. Each value is associated with a unique key, which acts as an identifier for that value within the dictionary. Unlike items in an array, items in a dictionary do not have a specified order. You use a dictionary when you need to look up values based on their identifier, in much the same way that a real-world dictionary is used to look up the definition for a particular word.
-
Number of key-value pairs in the dictionary.
Declaration
var count: Double { get } -
An array containing the keys of the dictionary in an unspecified order.
Declaration
var keys: Array { get } -
An array containing the values of the dictionary in an unspecified order.
Declaration
var values: Array { get } -
trueif the dictionary does not contain any key-value pairs,falseotherwise.Declaration
var isEmpty: Bool { get } -
Compares two values for equality.
The
equalsfunction is invoked using infix notation as in the following code snippet:lhs == rhs.Declaration
func equals(_ lhs: Dictionary) -> BoolParameters
lhsA value.
rhsAnother value.
Return Value
trueif thelhsandrhsare equal,falseotherwise. -
Returns a new dictionary where the value of
keyis updated tovalue.Declaration
func updatingValue(_ value: Any, forKey key: Any) -> DictionaryParameters
valueThe new value.
keyA dictionary key.
Return Value
A new dictionary where the value of
keyis updated tovalue.