Ruby on Rails ActiveSupport or plain Ruby way of merging arrays into a hash
- by randombits
What's a smart way of using ActiveSupport or perhaps regular built in Ruby functionality to take two arrays and merge them into a hash where each element in an array matches the element in a parallel array? imagine two arrays:
names = ["Danny", "Johnny"]
ages = ["25", "32"]
The end result should be a hash that looks like:
{"Danny" => "25", "Johnny" => "32"}