Dart Programming - for in Loop



The for...in loop is used to loop through an object's properties.

Syntax

Following is the syntax of for in loop.

for (variablename in object){  
   statement or block to execute  
}

In each iteration, one property from the object is assigned to the variable name and this loop continues till all the properties of the object are exhausted.

Usage of For in Loop

Example

void main() { 
   var obj = [12,13,14]; 
   
   for (var prop in obj) { 
      print(prop); 
   } 
} 

Output

It should produce the following output

12 
13 
14 
dart_programming_loops.htm
Advertisements