The syntax of the foreach loop is:
foreach loopVariable in originalVariable {
doSomething(loopVariable)
}
OR
foreach(loopVariable in originalVariable) {
doSomething(loopVariable)
}
OR (if only one statement in the statement block)
foreach loopVariable in originalVariable:
doSomething(loopVariable)
The loop above would go through each of the values in originalVariable, assigning the value of variable loopVariable to each of those values in turn, one by one, and then executing the loop statements. The originalVariable may be either a vector or an array. The loopVariable does not (and should not) need to be previously declared.