Last active
December 17, 2015 04:18
-
-
Save covard/5549206 to your computer and use it in GitHub Desktop.
Transform array of hashes into a hash
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
# how to take an array of hashes and transform it into a hash | |
ary = [{a: :b}, {c: :d}] | |
ary.reduce Hash.new, :merge | |
# output {:a=>:b, :c=>:d} | |
# Happy Rubying =) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment