上QQ阅读APP看书,第一时间看更新
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: