From: Rodrigo Rosenfeld Rosas Date: 2013-08-18T20:53:23-03:00 Subject: [ruby-core:56736] Re: [ruby-trunk - Feature #7739] Define Hash#| as Hash#reverse_merge in Rails --f46d043c8262793a1b04e44187db Content-Type: text/plain; charset=ISO-8859-1 Yes, you're right, I'm convinced now. +1 for it aliasing #| to #reverse_merge. Em 18/08/2013 18:25, "alexeymuranov (Alexey Muranov)" escreveu: > > Issue #7739 has been updated by alexeymuranov (Alexey Muranov). > > > rosenfeld (Rodrigo Rosenfeld Rosas) wrote: > > > I'm not sure to be honest. I believe that's because in my head when I > perform set1 |= set2 I read it as "discard any duplicate values in set2 > when merging the values to set1" or "merge all values from set2 that are > not present in set1". I never think of it as "remove any values in set1 > that also happen to be present in set 2 then add all values of set2 to > set1". > > How it this different from the proposed behavior for hashes? hash1 |= > hash2 discards any duplicate values in hash2 and adds the rest to hash1. > ---------------------------------------- > Feature #7739: Define Hash#| as Hash#reverse_merge in Rails > https://bugs.ruby-lang.org/issues/7739#change-41261 > > Author: alexeymuranov (Alexey Muranov) > Status: Assigned > Priority: Normal > Assignee: matz (Yukihiro Matsumoto) > Category: core > Target version: next minor > > > =begin > I suggest for to define (({Hash#|})) as (({Hash#reverse_merge})) in > ((*Rails*)), in my opinion this would correspond nicely to (({Set#|})), to > the logical (({#||})) and to the bitwise (({#|})): > > { :a => 1, :b => 2 } | { :b => 1, :c => 2 } # => { :a => 1, :b => 1, :c > => 2 } > =end > > > > -- > http://bugs.ruby-lang.org/ > --f46d043c8262793a1b04e44187db Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Yes, you're right, I'm convinced now. +1 for it alia= sing #| to #reverse_merge.

Em 18/08/2013 18:25, "alexeymuranov (Alexey= Muranov)" <redmine@ruby-l= ang.org> escreveu:

Issue #7739 has been updated by alexeymuranov (Alexey Muranov).


rosenfeld (Rodrigo Rosenfeld Rosas) wrote:

> I'm not sure to be honest. I believe that's because in my head= when I perform set1 |=3D set2 I read it as "discard any duplicate val= ues in set2 when merging the values to set1" or "merge all values= from set2 that are not present in set1". I never think of it as "= ;remove any values in set1 that also happen to be present in set 2 then add= all values of set2 to set1".

How it this different from the proposed behavior for hashes? =A0hash1 |=3D = hash2 discards any duplicate values in hash2 and adds the rest to hash1. ----------------------------------------
Feature #7739: Define Hash#| as Hash#reverse_merge in Rails
https://bugs.ruby-lang.org/issues/7739#change-41261

Author: alexeymuranov (Alexey Muranov)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


=3Dbegin
I suggest for to define (({Hash#|})) as (({Hash#reverse_merge})) in ((*Rail= s*)), in my opinion this would correspond nicely to (({Set#|})), to the log= ical (({#||})) and to the bitwise (({#|})):

=A0 { :a =3D> 1, :b =3D> 2 } | { :b =3D> 1, :c =3D> 2 } =A0# = =3D> { :a =3D> 1, :b =3D> 1, :c =3D> 2 }
=3Dend



--
http://bugs.ruby-l= ang.org/
--f46d043c8262793a1b04e44187db--