Issue #7739 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).


david_macmahon (David MacMahon) wrote:
> On Aug 17, 2013, at 5:44 PM, rosenfeld (Rodrigo Rosenfeld Rosas) wrote:
>  
>  > As I stated in #8772, I believe #| being implemented as #reverse_merge instead of #merge is confusing. I believe the original example in the description makes sense though.
>  
>  Why do you think that...
>  
>      {a:1, b:1} | {b:2, c:2) #=> {a:1, b:2, c:2} # merge-like
>  
>  ...is less confusing than...
>  
>      {a:1, b:1} | {b:2, c:2) #=> {a:1, b:1, c:2} # reverse_merge-like
>  
>  ...?

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 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".

----------------------------------------
Feature #7739: Define Hash#| as Hash#reverse_merge in Rails
https://bugs.ruby-lang.org/issues/7739#change-41259

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/