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)

···

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

Adam Akhtar wrote:

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)

begin
   something
end while condition

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

begin
something
end while condition

Or

begin
something
end until condition

Regards,

Park Heesob

···

2008/9/7 Adam Akhtar <adamtemporary@gmail.com>:

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)
--
Posted via http://www.ruby-forum.com/\.

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