From: "phluid61 (Matthew Kerwin)" Date: 2013-08-19T07:08:00+09:00 Subject: [ruby-core:56733] [ruby-trunk - Feature #7739] Define Hash#| as Hash#reverse_merge in Rails Issue #7739 has been updated by phluid61 (Matthew Kerwin). =begin I still believe the original proposal is the most useful: class Hash def | other_hash other_hash.merge self end end Or, if taking the code from active support: class Hash def reverse_merge(other_hash) other_hash.merge(self); end alias :| :reverse_merge end Use-case: def foo options={} options |= {a:1, b:2} end Note: this is different from kwargs if you're going to operate on the hash as a whole: def foo options={} options |= {a: 1, b: 2} do_something_with options end def bar a: 1, b: 2, **options #do_something_with( {a: a, b: b} + options ) ?? end =end ---------------------------------------- Feature #7739: Define Hash#| as Hash#reverse_merge in Rails https://bugs.ruby-lang.org/issues/7739#change-41262 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/