Re: Where does Return return to?
- To: mathgroup at smc.vnet.net
- Subject: [mg48629] Re: Where does Return return to?
- From: koopman at sfu.ca (Ray Koopman)
- Date: Tue, 8 Jun 2004 00:48:27 -0400 (EDT)
- References: <ca1d48$d0r$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
This may make the problem clearer.
Why does Return exit Block in func1 but not in func2 or func3?
In[1]:= func1 := Block[{L = 2},
While[L > 1, If[True, Return[1]]; L--]; 0]
In[2]:= func2 := Block[{L = 2},
While[If[True, Return[1]]; --L > 1]; 0]
In[3]:= func3 := Block[{},
Do[If[True, Return[1]], {L,2,2,-1}]; 0]
In[4]:= func1
Out[4]= 1
In[5]:= func2
Out[5]= 0
In[6]:= func3
Out[6]= 0
- Follow-Ups:
- Re: Re: Where does Return return to?
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Re: Where does Return return to?