I have two unique hashes and I want to write a code to create a single nested hash from those two. I understand one can create a nested hash manually, but I'd rather be able to write code to do that.
cats = {"name" => "alpha", "weight" => "10 pounds"}
dogs = ("name" => "beta", "weight"=>"20 pounds"}
Ideally my nested hash would resemble:
pets = {"dogs"=>{"name"=>"beta", "weight"=>"20 pounds"}, "cats"=>{"name"=>"alpha", "weight"=>"10
pounds"}}
I'd really appreciate it if someone could break down the code to do the above for me. Thank you!!
cats = { name: "alpha", ... }is a shorter way of doing this. Thencats[:name]for example.