From: Wu Xiaoyi Date: 2009-06-12T16:41:27+09:00 Subject: About 'dup' Hello, mainarray=Hash.new(0) subarray=Hash.new(0) thirdarray={ 'a' => '0', 'b' => '0', 'c' => '0', } subarray['first']=thirdarray.dup subarray['second']=thirdarray.dup mainarray['x']=subarray.dup mainarray['y']=subarray.dup mainarray['x']['first']['c']=56 mainarray['y']['first']['c']=73 p mainarray the result is: {"x"=>{"second"=>{"a"=>"0", "b"=>"0", "c"=>"0"}, "first"=>{"a"=>"0", "b"=>"0", "c"=>73}}, "y"=>{"second"=>{"a"=>"0", "b"=>"0", "c"=>"0"}, "first"=>{"a"=>"0", "b"=>"0", "c"=>73}}} Why did the mainarray['x']['first']['c'] become 73,too? dup does not work if I use it twice? -- Posted via http://www.ruby-forum.com/.