From: "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>
Date: 2013-08-10T20:56:49+09:00
Subject: [ruby-core:56511] [ruby-trunk - Feature #6225] Hash#+


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


I agree that the operation not being an addition is not a big deal. No one would expect it from a Hash. Groovy does have this operator working exactly as a merge and I don't see anyone complaining about it. But I don't see any problems either with calling it #|. I would be fine with either "hash + another_hash" or "hash | another_hash" as an alias for hash.merge(another_hash).

As a side note, yesterday I missed a method to perform Array#| in a way that work directly in the array (like #|! if it was possible). I had a code similar to this:


dependencies = Thread.current[:_my_app_dependencies]
dependencies |= new_dependencies # won't work as expected, of course, since I wanted to store it under Thread.current[:_my_app_dependencies]

But as I said, this is just an aside note, not related to this ticket.

----------------------------------------
Feature #6225: Hash#+
https://bugs.ruby-lang.org/issues/6225#change-41065

Author: trans (SYSTEM ERROR)
Status: Rejected
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


Strings and Arrays can be combined with #+. I don't see any reason not to allow Hashes to do so as well.

  class Hash
    alias :+ :merge
  end



-- 
http://bugs.ruby-lang.org/