Skip to content

Instantly share code, notes, and snippets.

@fronx
Created August 18, 2011 19:14
Show Gist options
  • Save fronx/1154895 to your computer and use it in GitHub Desktop.
Save fronx/1154895 to your computer and use it in GitHub Desktop.
class Hash
def map_values(&block)
merge(self) { |k, v| block.call(v) }
end
end
puts ({:a => 1, :b => 2}.map_values { |x| x * 2})
# => {:a=>2, :b=>4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment