Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
A shorthand version used for looping through an enumeration completely
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
So, the for-each loop to the rescue.
0:00
Again, useful when you wanna process
everything in a list or in an array.
0:02
Every time you wanna
process through everything.
0:05
It's definitely more legible and
you want to use this.
0:07
If you see the old loop looping
over an array, convert it,
0:11
make it more readable, right?
0:13
Again, in other languages sometimes
this is called a for-in loop or
0:15
an enhanced for-loop.
0:18
So, let's just go really quick and
we'll do the for-each.
0:20
We'll switch that over,
I want you back, Jackson old school.
0:23
Was a Jackson five joke, it fell flat.
0:28
They always do.
0:34
All right, so
I'm gonna grab this over here.
0:36
So, I'm gonna write this string,
Jackson and Jackson's,
0:41
and then I can get rid of this right here.
0:45
Clean, precise.
0:49
I think everybody kinda
understands what's going on there.
0:51
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up