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 trialVamsi Pavan Mahesh Gunturu
4,541 PointsWhat 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ć
6,004 PointsHi,
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.
Vamsi Pavan Mahesh Gunturu
4,541 PointsVamsi Pavan Mahesh Gunturu
4,541 PointsHi, Thanks for your answer, yes it might be optional. But not a separator
Vedran Brnjetić
6,004 PointsVedran Brnjetić
6,004 PointsLike I said, I never coded in ruby.
In the aricle I linked
Ruby until Statement:
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