Learn Python practically
and Get Certified.
Reference Materials
Learn Python Interactively
Try Programiz PROLearn Python practically
and Get Certified.
Try Programiz PRO!
Learn Python practically
and Get Certified.
Swift Dictionary Methods
Dictionary is an unordered collection that stores elements in key/value pairs. Swift provides various methods that allow us to perform different operations on dictionary elements. For example, the min()
method returns the minimum key/value pair in the dictionary.
In this reference, you will find various dictionary methods that are available in Swift.
Swift Dictionary capacity
returns the total number of elements
Swift Dictionary count
returns the total number of elements present
Swift Dictionary enumerated()
iterates through key-value pairs of a dictionary
Swift Dictionary filter()
returns elements that satisfy given condition
Swift Dictionary first
returns the first key/value pair
Swift Dictionary keys
returns just the keys of the dictionary
Swift Dictionary mapValues()
transforms all values of dictionary
Swift Dictionary updateValue()
updates the value for the given key
Swift Dictionary contains()
checks whether key or value is present or not
Swift Dictionary forEach()
iterates through each element of a dictionary
Swift Dictionary isEmpty
checks if the dictionary is empty or not
Swift Dictionary max()
returns the max key-value pair in the dictionary
Swift Dictionary min()
returns the min key-value pair in the dictionary
Swift Dictionary randomElement()
returns a random key-value pair from dictionary
Swift Dictionary removeAll()
removes all key-value pairs from the dictionary
Swift Dictionary removeValue()
removes the certain key and its associated value
Swift Dictionary sorted()
sorts the dictionary in a specific order