Ask Your Question
1

Does Ruby have a "do ... while" loop?

asked 2022-12-24 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-07-30 15:00:00 +0000

nofretete gravatar image

Yes, Ruby has a "do .. while" loop, but it is called the "begin .. while" loop in Ruby. Here's an example:

i = 0
begin
  puts i
  i += 1
end while i < 10

This code will print the numbers from 0 to 9.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-24 11:00:00 +0000

Seen: 9 times

Last updated: Jul 30 '22