Swift Dictionary values

The values property returns just the values of the dictionary.

Example


values Syntax

The syntax of the dictionary values property is:

dictionary.values 

Here, dictionary is an object of the Dictionary class.


values Return Values

The values property returns an array of all the values of dictionary.


Example 1: Swift Dictionary values

Output

[18, 20, 34]

In the above example, we have used the values property to return an array of just the values of the information dictionary.


Example 2: Using values With for Loop

Output

20
34
18

Here, we have used the for loop to iterate through all the values of the informations dictionary.

Finally, all the values of informations are printed one at a time.