Issue #7739 has been reported by alexeymuranov (Alexey Muranov). ---------------------------------------- Feature #7739: Define Hash#| as Hash#reverse_merge in Rails https://bugs.ruby-lang.org/issues/7739 Author: alexeymuranov (Alexey Muranov) Status: Open Priority: Normal Assignee: Category: core Target version: =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
on 2013-01-24 13:57
on 2013-01-24 19:32
I would personally love a more concise way to merge/reverse_merge hashes. Would you also propose Hash#& as merge? P.S. in your example, a reverse_merge should result in :b => 2
on 2013-01-24 23:30
Issue #7739 has been updated by drbrain (Eric Hodel). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) Target version set to next minor We don't have any operations that use mathematical or logical operators for Hash. It seems confusing to introduce an operator (|) when a name (reverse_merge) exists. Hash and Set are different data structures and serve different purposes. The design of Hash should not be based on the design of Set. ---------------------------------------- Feature #7739: Define Hash#| as Hash#reverse_merge in Rails https://bugs.ruby-lang.org/issues/7739#change-35585 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
on 2013-01-25 10:33
Issue #7739 has been updated by alexeymuranov (Alexey Muranov).
=begin
nathan.f77 (Nathan Broadbent) wrote:
> I would personally love a more concise way to merge/reverse_merge
hashes. Would you also propose Hash#& as merge?
(({Hash#&})) would be the intersection of two hashes, i think:
{ :a => 1, :b => 2 } & { :b => 1, :c => 2 } # => { :b => 1 }
> P.S. in your example, a reverse_merge should result in :b => 2
You are right, sorry about the confusion, it should be
{ :a => 1, :b => 2 } | { :b => 1, :c => 2 } # => { :a => 1, :b => 2,
:c => 2 }
=end
----------------------------------------
Feature #7739: Define Hash#| as Hash#reverse_merge in Rails
https://bugs.ruby-lang.org/issues/7739#change-35631
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
on 2013-01-25 10:43
Issue #7739 has been updated by alexeymuranov (Alexey Muranov). @drbrain, my idea was to propose a concise syntax to merge hashes (one or the other direction), and `#|` looked like a natural candidate. ---------------------------------------- Feature #7739: Define Hash#| as Hash#reverse_merge in Rails https://bugs.ruby-lang.org/issues/7739#change-35632 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
on 2013-02-08 05:10
Issue #7739 has been updated by PikachuEXE (Pikachu Leung). I prefer using the name `#reverse_merge` Since we don't have operator for `#merge` Using an explicit name makes people try to understand what they are doing ---------------------------------------- Feature #7739: Define Hash#| as Hash#reverse_merge in Rails https://bugs.ruby-lang.org/issues/7739#change-36033 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
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.