While loop : execute code and THEN check condition

Im sure this was possible in C but in ruby i couldnt find something
similiar.

I want a control structure which will execute the code first and then
check if the condition is true or not. something like

do

something

while (condition)

Adam A. wrote:

while (condition)
begin
something
end while condition

2008/9/7 Adam A. [email protected]:

while (condition)

Posted via http://www.ruby-forum.com/.

begin
something
end while condition

Or

begin
something
end until condition

Regards,

Park H.

Although
begin

end while condition

is the idiomatic way to do this I often write my loops as follows

loop do

break if/unless condition

end

I prefer it even more if my code can be refactored to

loop do

return …

end

Cheers
Robert


C’est véritablement utile puisque c’est joli.

Antoine de Saint Exupéry