Given array1:
[:lien_amount, :contact_number]
Given Array2:
[[14646.75, nil], [69454.63, nil], [24989.53, nil], [74455.69, nil], [140448.19, nil], [12309.34, nil]]
I want:
{
lien_amount: [14646.75, 69454.63, 24989.53, 74455.69,140448.19, 12309.34],
contact_number: [nil, nil, nil, nil, nil, nil]
}
So I want to match the keys of one array with the values in the array of arrays.
I am looking for a one-line-of-code solution. What I have tried:
array2.flat_map {|a| a.zip(array1)}
This returns the following:
[[14646.75, :lien_amount], [nil, :contact_number], [69454.63, :lien_amount], [nil, :contact_number], ...
Not what I was looking for. But gives an idea of the type of solution I want.