Exercise 3: Flip the Keys and Values

Flip the keys and values of a dictionary.

Problem statement

There’s a method on hashes that flips keys and values. Find that method in the Ruby Hash documentation and try to flip the keys and values of this hash.

Example

input_hash = {
:one => 'uno',
:two => 'dos',
:three => 'tres'
}

The output should look like this:

{ 'uno' => :one, 'dos' => :two, 'tres' => :three }

Try it yourself

Press + to interact
def flip_keys_vals(input_hash)
result = {}
# Start your code here
return result
end