Invert a Hash
Ruby's Hash
includes the method invert
, which takes a hash and returns it with the keys and values reversed.
2.2.2 :001 > {blackhawks: 'chicago'}.invert
=> {"chicago"=>:blackhawks}
Tweet
Ruby's Hash
includes the method invert
, which takes a hash and returns it with the keys and values reversed.
2.2.2 :001 > {blackhawks: 'chicago'}.invert
=> {"chicago"=>:blackhawks}
Tweet