One minute
Hash Deep Merge 🔄
Use deep_merge
instead of merge
if you want to merge two hash objects recursively 🌟
Code snippet 📌
❯ person1 = { name: 'Rishi', address: { area: 'Baner' } }
❯ person2 = { name: 'Rishi', address: { city: 'Pune' } }
❯ person1.merge(person2)
❯ {:name=>"Rishi", :address=>{:city=>"Pune"}}
❯ person1.deep_merge(person2)
❯ {:name=>"Rishi", :address=>{:area=>"Baner", :city=>"Pune"}
Read other posts
comments powered by Disqus