From: Robert Klemme Date: 2011-12-11T05:24:21+09:00 Subject: Re: Learn To Program (Chris Pine) - Building and Sorting Array On Sat, Dec 10, 2011 at 12:02 AM, Emeka Patrick wrote: > Thanks so much for getting back to me and for your kind words. Really > big encouragement for someone just starting out and feeling a wee bit > lost at times. As well, I must say the willingness of people in the Ruby > community to offer help has really been pretty amazing. It's among the most friendly online communities I have come across - if not the most friendly. >> That would also be correct. One other small item, normally code is >> indented >> (Ruby standard is 2 spaces) another level inside a control statement >> (if/while/else and such) to make it slightly easier to read the code. > > I've been trying to do this as well as line up certain elements of code, > but keep slipping in my enthusiasm to get it all out there. Def. need to > try harder to keep it up. What about using Tab to indent, is there  any > reason that might be frowned upon? Btw, I'm using TextMate. I think people don't like the large indent especially when posting code in emails or forums because there usually line width is limited or lines are wrapped automatically. > Oh wow, ok, I think I get it. This is super clean too. Much nicer than > what I originally had. Now, one last question, I need response = > gets.chomp in the first instance just to define what the variable stands > for, correct? Partly. The more important aspect in this case is that you need to have a value which is checked as while condition. > It's not actually until the second instance where I'm > soliciting input from the user, or actually is it more so the first > instance both defines the variable and solicits  input from the user > while the second instance solicits input in a continuous loop until it > gets broken, i.e. when a user enters an empty string? Exactly (the latter). You could as well do this avoiding the duplicate "gets.chomp": responses = [] while (response = gets.chomp) != '' responses << response end puts responses.sort Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/