Array to Hash Ruby

后端 未结 9 491
无人及你
无人及你 2021-01-29 17:43

Okay so here\'s the deal, I\'ve been googling for ages to find a solution to this and while there are many out there, they don\'t seem to do the job I\'m looking for.

Ba

9条回答
  •  感情败类
    2021-01-29 18:14

    This is what I was looking for when googling this:

    [{a: 1}, {b: 2}].reduce({}) { |h, v| h.merge v } => {:a=>1, :b=>2}

提交回复
热议问题