From: John Maclean Date: 2006-02-06T20:54:12+09:00 Subject: Re: Adding user input to a hash whoa! Thanks. It works but asa novice to this language I would never have known of questions.inject({}) { |hash, question| ... pouring over this line and ri Hash. On Mon, 6 Feb 2006 20:32:13 +0900 Levin Alexander wrote: > On 2/6/06, John Maclean wrote: > > > if user_input.chomp! != "qq" > > ask_list.each_value = user_input # this line don't work > > How could it, you are trying to assign to a method. > > Try this: > > questions = %w{Name Job} > answers = questions.inject({}) { |hash, question| > print "#{question}: " > answer = gets.chomp > break hash if answer == "q" > hash[question] = answer > hash > } > p answers > > -Levin -- John Maclean MSc (DIC) 07739 171 531