Forum: Ruby-core [Rejected] Bring shortcut methods to Hash

F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2014-04-28 03:57
(Received via mailing list)
Issue #9778 has been updated by Nobuyoshi Nakada.

Status changed from Open to Rejected

----------------------------------------
Feature #9778: Bring shortcut methods to Hash
https://bugs.ruby-lang.org/issues/9778#change-46344

* Author: Nathaniel Symer
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: next minor
----------------------------------------
My obsession with easy syntax annoys me when I see `Hash#merge` does not
have a shortcut in the form of a mathematical operation (like `-` or
`+`).

~~~ruby
h_one = { :foo => "bar", :this => "that", :all => "nothing" }
h_two = { :foo => "this", :ruby => "awesome" }

# this isn't as pretty
h_one.merge(h_two)
  =>  { :foo => "this", :this => "that", :all => "nothing", :ruby =>
"awesome" }

# as this
h_one+h_two
  => { :foo => "this", :this => "that", :all => "nothing", :ruby =>
"awesome" }`
~~~

Why doesn't this exist in Ruby?
This topic is locked and can not be replied to.