Project

General

Profile

Bug #11501

Updated by studio3104 (Satoshi SUZUKI) about 9 years ago

When creating a new hash using { **hash1, **hash2 } literal, 
 there are different behaviors between 2.2.0 or later and 2.1.7 or earlier like below. 

 * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13] 
 * ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0] 

 ~~~ 
 [1] pry(main)> hash1 = { duplicate_key: 1, key: 1 } 
 => {:duplicate_key=>1, :key=>1} 
 [2] pry(main)> hash2 = { duplicate_key: 3 } 
 => {:duplicate_key=>3} 
 [3] pry(main)> { **hash1, **hash2 } 
 => {:duplicate_key=>3, :key=>1} 
 [4] pry(main)> 
 ~~~ 

 * ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-darwin13.0] 

 ~~~ 
 [1] pry(main)> hash1 = { duplicate_key: 1, key: 1 } 
 => {:duplicate_key=>1, :key=>1} 
 [2] pry(main)> hash2 = { duplicate_key: 3 } 
 => {:duplicate_key=>3} 
 [3] pry(main)> { **hash1, **hash2 } 
 => {:duplicate_key=>1, :key=>1} 
 [4] pry(main)> 
 ~~~ 

 It seems that the behavior has changed from 2.2.0, however there is no mention mentions in any documents as far as I searched. 

 > * https://github.com/ruby/ruby/blob/v2_2_0/NEWS 
 > * https://www.ruby-lang.org/en/news/2014/12/25/ruby-2-2-0-released/ 

 Is this intended change? 
 Please check this and give me a opinion. 
 Warm Regards.

Back