From: "Kevin Börgens" Date: 2004-11-10T01:38:33+09:00 Subject: Re: Iterating trough hash Hi! > #!/usr/bin/env ruby > > h = {"john" => 41, "mary" => 31, "fred" => 10} > h.each_key do |person1| > h.each_key do |person2| > puts "#{person1} shakes hands with #{person2}. " + > "Together they are #{h[person1] + h[person2]} years old." > end > end No, this programm would iterate like this john john john mary john fred mary john mary mary mary fred fred john fred mary fred fred > I'm not very clear on what you were aiming for with the if statement, > but if you tell me, I can probably add that back a little slimmer too. Therefore I used the example with shaking hands. You don't shake hands with yourself and it doesn't matter who is person1 or person2 TIA, Kevin