From: gabriele renzi Date: 2005-12-13T08:12:38+09:00 Subject: Re: Idiom wanted: do-while Adam Shelly ha scritto: > So I was working on the quiz solution, and > I had some code like this: > > b = simulate board,m > while another_turn?(b,m) > b = simulate b,m > end > > > If I was doing this in C, I'd use a do-while loop instead, to avoid > repeating the line outside the loop: > > b = board; > do { > b = simulate(b.m); > } > while ( another_turnta(b,m)); > > What's the do-while idiom in ruby? you could do begin ... end while somecondition but I seem to recall it is somewhat "deprecated" and you should follow James' suggestion > I ended up with this, but it needs an extra flag variable: > > b,taketurn = board,true > while taketurn > b = simulate b,m > taketurn = another_turn?(b,m) > end > > Is there a ruby idiom for do-while? > > -Adam > >