From: "Jan E." Date: 2012-10-05T04:01:53+09:00 Subject: Re: Calculation of heights Hi, so the question in your other thread has been answered? The problem in this case, again, is that you somehow don't see the obvious solution but instead do all kinds of complicated things with nested loops and such. Why do you need the intermediate arrays when you could simply store the value in the hash? Also be careful with variable naming. There is no "alturas". Just stick with English. So dump the arrays and loops and simply save the height directly in the hash with the name as the key: heights = {} ... name = gets.chomp height = gets.chomp heights[name] = height That's it. If you do want to use the arrays for whatever reason, you mustn't use a nested loop. Instead, you must iterate over the arrays parallely. Like this, for example: a.each_with_index do |name, i| # pass an index for each element # get height from other array using the index height = b[i] heights[name] = height end -- Posted via http://www.ruby-forum.com/.