Rails mapping array of hashes onto single hash

后端 未结 4 1080
情书的邮戳
情书的邮戳 2021-01-30 12:08

I have an array of hashes like so:

 [{\"testPARAM1\"=>\"testVAL1\"}, {\"testPARAM2\"=>\"testVAL2\"}]

And I\'m trying to map this onto sin

4条回答
  •  粉色の甜心
    2021-01-30 12:51

    How about:

    h = [{"testPARAM1"=>"testVAL1"}, {"testPARAM2"=>"testVAL2"}]
    r = h.inject(:merge)
    

提交回复
热议问题