Hash1 = {
map1: {city: 'Berlin', country: 'Germany'},
map2: {city: 'Toronto', country: 'Canada'},
map3: {city: 'Boston', country: 'USA' }
}
Okay so I want to build a hash that looks as follows:
newHash = {
Berlin: 'map1',
Toronto: 'map2',
Boston: 'map3'
}
How do I loop through Hash1 and build newHash.
Hash1.each_with_object({}) do |(key, value), acc|
# what do I do inside this loop?
end