Ruby Redo
Ruby has a keyword redo
that you might see inside a block. It causes the unconditional re-execution of the block, with the same parameter bindings as the current execution.
Here it is, causing an endless loop:
n = 0
until n == 1 do
puts n
n += 1
redo
end
redo
does not evaluate the 'until' condition, so the likelihood of it causing an endless loop is high.
I'd love to see a practical application. It seems to me that redo
would have to be inside a conditional, based on some information coming from outside the loop-- information we are certain will eventually be false.
That's a lot to ask; I would avoid redo
in most cases.