From: nagachika00@... Date: 2015-12-12T08:26:51+00:00 Subject: [ruby-dev:49432] [Ruby trunk - Bug #11501] About priority of a hash element when using {**hash1, **hash2} literal Issue #11501 has been updated by Tomoyuki Chikanaga. Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE Add description to NEWS about this on `ruby_2_2` branch (I committed in doc/NEWS-2.2.0 on trunk and backport it) at r53051. ---------------------------------------- Bug #11501: About priority of a hash element when using {**hash1, **hash2} literal https://bugs.ruby-lang.org/issues/11501#change-55492 * Author: Satoshi SUZUKI * Status: Closed * Priority: Normal * Assignee: Tomoyuki Chikanaga * ruby -v: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0] * Backport: 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE ---------------------------------------- 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 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. -- https://bugs.ruby-lang.org/