ruby - Convert two arrays into an array of Hash pairs -
i have 2 arrays:
dates = [1,2,3] values = [10,20,30]
how can combine them this?
[{date:1,value:10},{date:2,value:20}...etc]
dates.zip(values).map{|k, v| {date: k, value: v}}
i have 2 arrays:
dates = [1,2,3] values = [10,20,30]
how can combine them this?
[{date:1,value:10},{date:2,value:20}...etc]
dates.zip(values).map{|k, v| {date: k, value: v}}
Comments
Post a Comment