From: salai Date: 2009-10-26T21:59:37+09:00 Subject: Hash Reverse ? I am preparing for my orals exam in Ruby (my last chance.. , If I fail the test, no more possible to study Computer Science related :-) ) http://codepad.org/foNb9Pd3 class Hash def hash_revert hash_new = Hash.new self.each {|key,value| if not hash_new.has_key?(key) then hash_new[value] = key end } return hash_new end end h = {2=>"a", 1=> "b", 3 =>"a", 4=> "a", 5 => "b", 6=>"c"} p h.hash_revert #--> {"a"=>4, "b"=>1, "c"=>6} or Should I get this ?? # => {"a"=>2, "b"=>1, "c"=>6} Because HASH is working like "Set" ?? many thanks in advance, salai.