Loops

Break


break [expression]


All loops can be terminated with a break statement. The break statement takes an optional expression that then becomes the value of the loop. Without a break statement, a loop has a nil value. For instance, the following function returns true if its parameter (array or frame) contains a nil slot:

HasNilSlot := func(arrayOrFrame)
begin
   return foreach value in arrayOrFrame do
      if value = nil then
         break true;
end;

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

Last modified: 1 DEC 1996