Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialanonymousperson
8,573 PointsIsn't this a for loop?
Isn't the playlist suppose to be the Playlist[1] since it is a let (Constant), or *Playlist[lastIndex] since it is a for loop?
playlistsArray += [playlistImageView0, playlistImageView1, playlistImageView2, playlistImageView3, playlistImageView4, playlistImageView5]
for index in 0..<playlistsArray.count {
let playlist = Playlist(index: index)
let playlistImageView = playlistsArray[index]
playlistImageView.image = playlist.icon
playlistImageView.backgroundColor = playlist.backgroundColor
}
1 Answer
Richard Lu
20,185 PointsYes, the 0 ..< playlistsArray.count is basically a range that you're looping through.
For example:
let playlistArray = ["0", "1", "2", "3", "4", 5"]
for index in 0...5 {
print(playlistArray[index])
}
so an output of the program would be:
0
1
2
3
4
5