Truls Alexander Tangstad <trulsat / hinux.hin.no> writes:

> >From the example in "Ruby User's Guide", section 9, "Iterators", there is an
> example of a while implemention. In Ruby 1.6.3 the code results in the
> following:
> 
> ruby> def WHILE(cond)
>     |    return if not cond
>     |    yield
>     |    retry
>     | end
>    nil
> ruby> i=0; WHILE(i<3) { print i; i+=1 }
> 0   nil
> 
> First off, i'm guessing the example is flawed, as 'i<3' is only evaluated
> once, so the WHILE should go into an infinite loop. 
> 
> The actual problem is that retry doesn't restart the loop.

Just to add some info:

This seems to work on 1.6.1, but not on 1.6.3 or 1.7.


Dave