John Maclean wrote:
> Chaps,
>
> Say you've got an hash that you are using to capturing user input....
> nearly there:-
>
>  #!/usr/bin/ruby -w
> def testwrite
>   ask_list = {
>               'Your name' => 'Nil',
>               'Your dob' => 'Nil',
>               }
>   ask_list.each_key {
>     |z| puts "#{z} : "
>     user_input = gets.chomp
>     if user_input.chomp! != "qq"
>       ask_list.each_value = user_input # this line don't work
>     end
>   }
> end
>
> testwrite

I'd choose a completely different design: I'd have questions in a list
(Arry) and answers in another list (Array) or Hash.

You could do:

questions = [
  'Your name',
  'Your job',
]

answers = questions.map |q|
  puts q
  gets.chomp
end

Reason is that your question list is likely constant over time and your
answers depend on each run.  If you put your original solution into a loop
for different users then you end up having old answers from someone still
in the hash.  Concurrency won't work either.

Kind regards

    robert