On 06-08-15, at 22:23, David Vallner wrote:

> On Wed, 16 Aug 2006 04:07:26 +0200, Eero Saynatkari  
> <eero.saynatkari / kolumbus.fi> wrote:
>> Since no-one mentioned it, how about a throw/catch solution?
>
> Throw / catch is for hairier nonlocal returns, he wanted to repeat  
> something using goto. Looping with a break or an end condition is  
> easier to understand (YMMV) if you don't need to get a result value  
> of any sort. But yes, that would also work. Especially since you  
> can implement any control construct with ruby's throw / catch if  
> you're stark raving mad enough.

Even if you need a return value you can break with a value. I.e.,

i = 0
loop do
   i = i + 1
   break i * i if i == 5
end

will return 25.

> David Vallner

--
Jeremy Tregunna
jtregunna / blurgle.ca


"One serious obstacle to the adoption of good programming languages  
is the notion that everything has to be sacrificed for speed. In  
computer languages as in life, speed kills." -- Mike Vanier