swap keys and values : invert « Hash « Ruby






swap keys and values


h = {:a=>1, :b=>2}

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

 

Related examples in the same category