官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 扎兰屯市| 揭西县| 阿克| 淅川县| 江西省| 内黄县| 个旧市| 镇巴县| 若尔盖县| 日照市| 西乌珠穆沁旗| 周口市| 兰溪市| 三江| 广元市| 曲阜市| 万州区| 新郑市| 尤溪县| 门源| 万安县| 娱乐| 沾益县| 南康市| 西乌| 锡林郭勒盟| 江油市| 嵩明县| 柳河县| 莱州市| 南丰县| 山阴县| 蚌埠市| 垫江县| 三穗县| 万州区| 宝鸡市| 安仁县| 安康市| 安塞县| 乃东县|