lundi 7 septembre 2020

Ruby - How to Merge a Hash into a method

I have this method

def method1
 {
  headers: { 'Content-Type' => 'application/json' }
 }
end

and this another method for merge a another key and value into this method1 hash, so

def merge_hash
  method1.merge!(body: { params: 123 }
end

so when i call method1 again i expect he returns a marged body and my questions is why not this happens or how i can do it?

Aucun commentaire:

Enregistrer un commentaire