Iterating with foreach

foreach with Frames


foreach value in frame do statement

foreach value in frame collect statement


Thankfully, you can use the same foreach loop to iterate over slots in a frame.

The following example prints all the slots in the frame x:

x := {a: 3, b: 9, c: 15};
foreach value in x do
   Print(value);
It prints:

3
9
15
The loop variable takes on each of the slot values in the frame. Note that you cannot count on the order in which the elements are accessed--it is undefined.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996