I'm new to Ruby and just finished my first program.

# simple quiz program
questions={"Question 1"=>"Answer 1",
           "Question 2"=>"Answer 2",
           "Question 3"=>"Answer 3",
           "Question 4"=>"Answer 4",
           "Question 5"=>"Answer 5",
           "Question 6"=>"Answer 6",
           "Question 7"=>"Answer 7",
           "Question 8"=>"Answer 8",
           "Question 9"=>"Answer 9",
           "Question 10"=>"Answer 10"}
score=0
i=0
while i<10
  puts questions.keys[i]
  if gets.chomp == questions.values[i]
    puts "Good answer !"
    score+=1
  else
    puts "Bad answer !"
  end
  i+=1
end

puts "Your score is #{score}/10."

When I past it in irb(0.9.5) it just runs fine, but when it runs with
ruby(1.8.7) or (1.9.2) the order of the questions changes.

Can someone explain me what goes wrong (and why)?

Thank you.

-- 
Posted via http://www.ruby-forum.com/.