Skip to content

Instantly share code, notes, and snippets.

@kotaroito
Created May 26, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotaroito/90b8f9613c764398881c to your computer and use it in GitHub Desktop.
Save kotaroito/90b8f9613c764398881c to your computer and use it in GitHub Desktop.
Ruby: Array to Hash
array = %w(a b c)
hash = Hash[array.collect.zip(array.map{|c| c.upcase})]
p hash
# {"a"=>"A", "b"=>"B", "c"=>"C"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment