foreachby Group Public on Friday September 18 2009 @ 13:17:50 (1/1 Points) |
|
| Language ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
foreach is a looping construct used to iterate the values in a list, set, map, or other collection.
Syntax
A simple collection of values can be enumerated with the foreach loop. This iterates through the items in the order defined by the collection itself. For example a vector→ will be iterated in the order of the elements added.
set %List% withvector One Two Three end foreach %Item% in %List% Notice %Item% end
A map, or name value pair, collection can be iterated with a form which allows getting at the key (or name) of the item as well as the value.
set %MapSet% with %One% 1 %Two% 22 %Three% 333 end foreach %Name% %Value% in %MapSet% Notice %Name% => %Value% end
Integer Sequence
As with most things the foreach takes an RValue→ as the value to be iterated. This allows you to specify a function call at that point.
A common use of this would be with the seqInteger→ function which creates a sequence of numbers. This is then comparable to a classic for-loop.
foreach %Index% in (seqInteger 10 20) Notice %Index% end
TestPlan foreach
