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

Iterating over an array

It would be nice if we could see a list of states in our array. Earlier, you learned that for...in loops work with sequences. Since our array is a sequence, we can use for...in loops to loop through each element. When working on a project that has arrays, it is helpful to use a print statement inside a for...in loop. This lets us print every item in our array to the Debug Panel. So, let's use a for...in loop to look at the contents of our array:

for state in states { 
  print(state) 
} 

This is how our code and output should now look:

主站蜘蛛池模板: 伊金霍洛旗| 大港区| 鸡东县| 霞浦县| 平罗县| 宾阳县| 怀远县| 公主岭市| 顺平县| 恩施市| 鄂托克前旗| 宣汉县| 山西省| 梅州市| 山东省| 土默特左旗| 马关县| 翁源县| 柏乡县| 仙游县| 恩施市| 封开县| 宾川县| 弥渡县| 堆龙德庆县| 肇源县| 东港市| 南阳市| 文登市| 曲麻莱县| 丰原市| 科技| 信阳市| 郑州市| 洪湖市| 漠河县| 隆尧县| 大新县| 灌南县| 昌江| 通海县|