- for loop is used when we want to
execute block of code known items.
- for in loop takes an expression as
iterator and iterate through the elements one at a time in sequence.
- The value of the element is bound to
var, which is valid and available for the loop body.
- Once the loop statements are executed
current iteration, the next element is fetched from the iterator, and we loop
another time. When there is no more element in iterator, for loop is ended.
void main() {
varcounter = [11, 12, 13];
for (varvalue in counter) {
print(value);
}
}
output
11
12
13