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

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:

主站蜘蛛池模板: 栾川县| 龙井市| 富顺县| 赤城县| 腾冲县| 东辽县| 宁强县| 灯塔市| 嵊泗县| 金沙县| 故城县| 玉环县| 婺源县| 湘阴县| 旬阳县| 临西县| 永吉县| 东至县| 乐安县| 沂南县| 横峰县| 福安市| 崇阳县| 高雄市| 乌苏市| 留坝县| 沅江市| 砀山县| 霍邱县| 巴彦淖尔市| 兴宁市| 宝丰县| 赤城县| 松潘县| 漳州市| 怀仁县| 电白县| 洮南市| 山西省| 甘泉县| 伊川县|