Programming in Dart: Control Flow & Collections

May 3 2022 · Dart 2.15, DartPad, DartPad

Part 1: Control Flow

06. Iterate Over Collections

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 05. Challenge: Play with For Loops Next episode: 07. Challenge: Practice Iterating

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Using the for-loop is pretty helpful but as you’ve seen, it’s required a bunch of setup as well as management. Often times, you’ll have a list of items and you’ll just want to loop over it to use the current item.

var movies = ['Aliens', 'Interstellar', '2001', 'Event Horizon'];
for() {

}
for(var movie) {

}
for(var movie in) {

}
for(var movie in movies) {

}
for(var movie in movies) {
    print(movie);
}
var sentence = 'this space for rent';
for (var word in sentence) {
    print(word);
}