Use a for-in loop to iterate through a list

Uses a for-in loop to iterate through a list.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

  - 
  
 assignStep 
 : 
  
 assign 
 : 
  
 - 
  
 list 
 : 
  
 [ 
 1 
 , 
  
 2 
 , 
  
 3 
 , 
  
 4 
 , 
  
 5 
 ] 
  
 - 
  
 sum 
 : 
  
 0 
 - 
  
 loopStep 
 : 
  
 for 
 : 
  
 value 
 : 
  
 v 
  
 # required, v = 1, 2, …, 5 
  
 in 
 : 
  
 ${list} 
  
 steps 
 : 
  
 - 
  
 getStep 
 : 
  
 assign 
 : 
  
 - 
  
 sum 
 : 
  
 ${sum + v} 
 - 
  
 returnStep 
 : 
  
 return 
 : 
  
 ${sum} 
  
 # sum is 15 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: