A
Adam Shelly
So I was working on the quiz solution, and
I had some code like this:
b =3D simulate board,m
while another_turn?(b,m)
b =3D 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 =3D board;
do {
b =3D simulate(b.m);
}
while ( another_turnta(b,m));
What's the do-while idiom in ruby?
I ended up with this, but it needs an extra flag variable:
b,taketurn =3D board,true
while taketurn
b =3D simulate b,m
taketurn =3D another_turn?(b,m)
end
Is there a ruby idiom for do-while?
-Adam
I had some code like this:
b =3D simulate board,m
while another_turn?(b,m)
b =3D 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 =3D board;
do {
b =3D simulate(b.m);
}
while ( another_turnta(b,m));
What's the do-while idiom in ruby?
I ended up with this, but it needs an extra flag variable:
b,taketurn =3D board,true
while taketurn
b =3D simulate b,m
taketurn =3D another_turn?(b,m)
end
Is there a ruby idiom for do-while?
-Adam