Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 22:24
Show Gist options
  • Save anonymous/4349097 to your computer and use it in GitHub Desktop.
Save anonymous/4349097 to your computer and use it in GitHub Desktop.
l = [{"a" => 1, "b" => 2}, {"a" => 5, "b" => 8}]
k = %w(a b)
k.map do |key|
l.inject(0) {|memo, hash| memo + hash[key]}
end
Hash[k.zip [6,10]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment