Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4616

Ruby: transform Hash-Keys

$
0
0

I have a Hash:

urls = [{'logs' => 'foo'},{'notifications' => 'bar'}]

The goal is to add a prefix to the keys:

urls = [{'example.com/logs' => 'foo'},{'example.com/notifications' => 'bar'}]

My attempt:

urls.map {|e| e.keys.map { |k| "example.com#{k}" }}

Then I get an array with the desired form of the keys but how can I manipulate the original hash?


Viewing all articles
Browse latest Browse all 4616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>