Iterating over dictionary values

Just like an array, we can iterate through our dictionary. However, there are a few differences. Since a dictionary is unordered, each time you loop through, the values will never be in the same order. With dictionaries, you can loop through both the values and keys.

Let's iterate over a dictionary's values using a for...in loop. Add the following to Playgrounds:

for value in dictPizzas.values { 
  print(value) 
}

Your code should now look like this:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.220.114