Mega Code Archive

 
Categories / Ruby / Hash
 

Swap keys and values

h = {:a=>1, :b=>2} h.invert        # => {1=>:a, 2=>:b}: swap keys and values