Actions
Bug #11501
closedAbout priority of a hash element when using {**hash1, **hash2} literal
ruby -v:
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
Description
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.
Is this intended change?
Please check this and give me a opinion.
Warm Regards.
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0