This is an excellent post.
Yonatan Laurence
11

Hey there! Thanks for your response!

invert is a method from Hash. It turns the keys into values and vice versa. Check out https://apidock.com/ruby/v1_9_3_125/Hash/invert

In this specific case:

Bike.models
# => {"city"=>0, "mountain"=>1, "eletric"=>2}
Bike.models.invert
# => {0=>"city", 1=>"mountain", 2=>"eletric"}
Like what you read? Give Jaimerson Araújo a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.