Two types of for loops are allowed:
for (int month = 1; month <= 12; month++) {
print(month);
}
and:
for (var object in flybyObjects) {
print(object);
}
The for-in
loop is convenient when simply iterating over an Iterable
collection. There is also a forEach
method that you can call on Iterable
objects that behaves like for-in
:
flybyObjects.forEach((object) => print(object));
or, more concisely:
flybyObjects.forEach(print);