Issue #7739 has been updated by david_macmahon (David MacMahon).


=begin
While it's true that "#|=" cannot be a name for "#reverse_merge!", "#|" still can (and should, IMHO) be a name for "#reverse_merge", so using "hash |= other_hash" would still be useful (IMHO).

FWIW, I don't think one can even define an "#<op>=" method for Ruby since the "LHS <op>= RHS" is treated as "LHS = LHS <op> RHS".  Attempting to define a "#<op>=" method from within Ruby results in a syntax error.  I think attempting to do so from a C extension just creates a method that will never be called.

    >> class Hash; def |=(o); self.reverse_merge!(o); end; end
    SyntaxError: (irb):1: syntax error, unexpected tOP_ASGN
    class Hash; def |=(o); self.reverse_merge!(o); end; end
                      ^
    (irb):1: syntax error, unexpected keyword_end, expecting end-of-input
            from /Users/davidm/local/bin/irb20:12:in `<main>'
    
    >> class Hash; def |(o); o.merge(self); end; end
    => nil
=end

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

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/