Feature #9778

Bring shortcut methods to Hash

Added by Nathaniel Symer 12 months ago. Updated 12 months ago.

[ruby-core:62179]
Status:Rejected
Priority:Normal
Assignee:Yukihiro Matsumoto

Description

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 +).

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?


Related issues

Duplicates Ruby trunk - Feature #6225: Hash#+ Rejected 03/30/2012

History

#1 Updated by Jeremy Kemper 12 months ago

Hash#+ rejected in #6225. Also see #7739 for Hash#|.

#2 Updated by Nobuyoshi Nakada 12 months ago

  • Description updated (diff)

#3 Updated by Nobuyoshi Nakada 12 months ago

#4 Updated by Nobuyoshi Nakada 12 months ago

#5 Updated by Nobuyoshi Nakada 12 months ago

#6 Updated by Nobuyoshi Nakada 12 months ago

  • Status changed from Open to Rejected

Also available in: Atom PDF