Jim Weirich wrote:
> On Sat, 2003-08-02 at 12:02, Yukihiro Matsumoto wrote:
....
>   def y
>     p = Proc.new { |n| return 1 if n == 5 }
>     10.times(&p)
>     2
>   end
> 
> Again, I would expect 1, but you seem to be saying it will be an error.
> 
> BTW, both return 1 in an not-very-recent version of 1.8.0.  (But that
> might be different in the previews).

Here is what I got with (ruby 1.8.0 (2003-08-03) [i386-mswin32]).

---
def X(t)
   m = 5 if t == 5
   return Proc.new { || 1 if m == 5 }
end

def Y(t)
   m = 5 if t == 5
   return Proc.new { || 1 if m == 5 }
end

def Z(t)
   m = 5 if t == 5
   return Proc.new { || return 1 if m == 5 }
end


p X(3).call, X(5).call # nil, 1
p Y(3).call, Y(5).call # nil, 1
p Z(3).call, Z(5).call # LocalJumpError
---


There was a time in somewhat more distant past (when there was
only one type of procs) were returns weren't allowed in any type of
procs (assuming my failing memory serves me right;-).
Thank you very much for pointing that this restriction is (half;-)gone.

/Christoph




>