Nested hash itself


#1

Is there a way to create a nested hash with the same hash?

if I have a hash h1 = {‘key’ => ‘value’}

Can I do that h1[‘abc’] = h1
so I will end up with the following hash h1 = ( ‘abc’ => {‘key’ => ‘value’}}


#2

Found it

I need to clone the hash

tmph = {}
tmph[key] = h.clone
h.clear
h = tmph.clone