Programming in Dart: Control Flow & Collections

May 3 2022 Dart 2.15, DartPad, DartPad

Part 1: Control Flow

6. Iterate Over Collections

Episode complete

Play next episode

Next
Save for later
About this episode
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 5. Challenge: Play with For Loops Next episode: 7. Challenge: Practice Iterating

This video Iterate Over Collections was last updated on May 3 2022

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

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

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);
}