Ruby - Hash Hash Cloning

Introduction

You can assign one Hash variable to another, in which case both variables will refer to the same hash, and a change made using either variable will affect that hash:

h1 = {'room1'=>'A', 
      'room2'=>'B', 
      'loc1' =>'C', 
      'loc2' =>'D' } 
h4 = h1 
h4['room1']='A new Room' 
puts(h1['room1'])        #=> 'A new Room' 

To make two variables to refer to the same items in different Hash objects, use the clone method to make a new copy:

h5 = h1.clone 
h5['room1'] = 'An even newer Room'  
puts(h1['room1'])        #=> 'A new room' (i.e., its value is unchanged)