From: E S Date: 2005-01-07T00:38:59+09:00 Subject: Re: Return from a block? Jamis Buck wrote: > On 08:17 Thu 06 Jan , Carlos wrote: > >>[Howard Lewis Ship , 2005-01-06 00.11 CET] >> >>>Is there a way to return control from the block to the method? >> >>next >> >>Good luck. > > > To elaborate a little more: > > a = proc { |i| next i+1 } > p a.call(5) > > Hope that helps. I can understand why 'return' behaves like it does, > but there are times I wish there was a more intuitive keyword for > returning a value from a block. 'next' just feels wrong to me. :( For just returning control, throw...catch should work, for returning a value, Kernel.callcc? But Mr. Buck's solution is certainly shorter. E