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

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:

主站蜘蛛池模板: 喜德县| 辛集市| 沅陵县| 宝鸡市| 托里县| 万州区| 安远县| 永春县| 本溪| 曲松县| 舞阳县| 合水县| 广丰县| 若尔盖县| 达日县| 乐陵市| 尖扎县| 海阳市| 江北区| 六枝特区| 阿城市| 义乌市| 武鸣县| 宁夏| 长汀县| 长海县| 丽水市| 汶川县| 阜阳市| 武强县| 桂平市| 平乐县| 南充市| 亳州市| 长丰县| 玉环县| 全椒县| 兰西县| 招远市| 武强县| 微山县|