From: Emeka Patrick Date: 2011-12-09T17:58:57+09:00 Subject: Learn To Program (Chris Pine) - Building and Sorting Array Hi, Super new to programming (1 week or so) and working through 'Learn to Program' to get an understanding of Ruby before moving on to trying my hand at Ruby on Rails. That being said I was having a bit of trouble working through the first "A Few Things To Try" in section 8.3. So, we're asked to write a program that asks us to type as many words as we want (one word per line, continuing until we just press 'ENTER' on an empty line) and then repeats the words back to us in an alphabetical order. After working on this for a bit, I came up with this program (see below), which seems to work. However I really want to understand everything and I don't think I fully get why it allows me to add things to the array and doesn't start to sort until I press enter on a blank line when i say if response != ' ' , but not when I make response == ' '. Basically, I don't think I get what I'm making response equal to, is it an empty string, or? Any help would be appreciated, as well as better ideas on how to go about writing this program. Thanks a ton, Emeka responses = [] while true response = gets.chomp if response != '' responses.push response else puts responses.sort break end end -- Posted via http://www.ruby-forum.com/.