0Pricing
Dart Academy · Lesson

for-in Over Collections

Walk every item without an index.

Skip the Index

Often you just want each item, not its position. The for-in loop hands you items one at a time with no counter to manage. ✨

The for-in Shape

Write for, a variable name, the keyword in, then your collection. Each pass binds the variable to the next element.

for (var item in items) {
  print(item);
}

All lessons in this course

  1. The Classic for Loop
  2. while and do-while Loops
  3. for-in Over Collections
  4. break, continue, and Labels
← Back to Dart Academy