Ruby: merge nested hash

前端 未结 9 1853
渐次进展
渐次进展 2020-11-30 06:25

I would like to merge a nested hash.

a = {:book=>
    [{:title=>\"Hamlet\",
      :author=>\"William Shakespeare\"
      }]}

b = {:book=>
    [{         


        
9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 07:04

    For rails 3.0.0+ or higher version there is the deep_merge function for ActiveSupport that does exactly what you ask for.

提交回复
热议问题