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

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:

主站蜘蛛池模板: 韩城市| 普陀区| 甘南县| 秦皇岛市| 普洱| 滁州市| 榆林市| 闽侯县| 玛沁县| 蛟河市| 建湖县| 常熟市| 望城县| 乐山市| 志丹县| 河源市| 永寿县| 宜兰县| 佛学| 宁城县| 永春县| 长泰县| 方城县| 东丰县| 甘谷县| 灵石县| 达尔| 资中县| 焦作市| 林州市| 米林县| 封开县| 平远县| 陈巴尔虎旗| 闵行区| 丽江市| 龙门县| 西乌珠穆沁旗| 科尔| 铅山县| 历史|