From: "Peña, Botp" Date: 2007-08-18T11:56:14+09:00 Subject: Re: Help with Arrays... From: William James [mailto:w_a_x_man@yahoo.com] # From: Robert Klemme # > I'd rather do this because the test is much easier: # > words = [] # > while ( line = gets ) # > words << line.chomp # > end # # The original poster wants the loop to end when the user presses # without entering any text. How about this? # words = [] # while line = gets and line.chomp! != "" # words << line # end in (my) practice, i usually go the simple way (like robert's), then refine it as needed by just adding the lines. words = [] while line=gets # break on eof break if line.strip!.empty? # break on empty lines including spaces next if line != /\w/ # special chars not allowed words << line # passed end sometimes, (as a nuby,) putting all conditions in one line may be dangerous. it is dificult to test, difficult to comment, and one may miss edge cases... i know it's not clever, but i value safety first, and it's cleaner and clearer to me.. but ymmv.. i haven't reach the mile yet :) kind regards -botp