Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Return[] within a Do Loop' topicStudent Support Forum > General > Archives > "Return[] within a Do Loop"

Next Comment >Help | Reply To Topic
Author Comment/Response
Mark W
05/27/99 4:03pm

According to Chapter 2.5.9 of the Mathematica book,
Return[] is supposed to exit ALL procedures and loops in a function.

If this is so, why does the following not work?

funct[]:=
   Module[ {},
      Do[Return[True],{1}];
      Print[False];
   ];

Evaluating funct[] yields False. The Return above quits the Do loop but does not quit the entire function. Is my understanding of the working of Return flawed?

Thanks,

Mark W

URL: ,

Subject (listing for 'Return[] within a Do Loop')
Author Date Posted
Return[] within a Do Loop Mark W 05/27/99 4:03pm
Re: Return[] within a Do Loop Forum Modera... 06/01/99 07:51am
Next Comment >Help | Reply To Topic