Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Loops Ruby Loops The Until Loop

What is the purpose of do!

In the while loop I see that, with or without do it works the same way. Can you please point to some resource regarding this?

1 Answer

Vedran Brnjetić
Vedran Brnjetić
6,004 Points

Hi,

I have never coded in ruby, so I went to http://www.tutorialspoint.com/ruby/ruby_loops.htm to find an answer. In while loop, do is the separator between the conditional and code. In other loops it is optional, as the separator can either be "do", ";" or a new line.

Hi, Thanks for your answer, yes it might be optional. But not a separator

Vedran Brnjetić
Vedran Brnjetić
6,004 Points

Like I said, I never coded in ruby.

In the aricle I linked

Ruby until Statement:

until conditional [do]
   code
end

Executes code while conditional is false. An until statement's conditional is separated from code by the reserved word do, a newline, or a semicolon.

That's why I named it a separator