Created
January 24, 2014 22:10
-
-
Save Aeramor/8607769 to your computer and use it in GitHub Desktop.
Ruby change keys of a hash with a hash map.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ages = { "Bruce" => 32, "Clark" => 28 } | |
mappings = {"Bruce" => "Bruce Wayne", "Clark" => "Clark Kent"} | |
Hash[ages.map {|k, v| [mappings[k], v] }] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment