Issue #5185 has been reported by Thomas Sawyer. ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not http://redmine.ruby-lang.org/issues/5185 Author: Thomas Sawyer Status: Open Priority: Normal Assignee: Category: lib Target version: 1.9.x Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2011-08-11 05:17
on 2012-01-12 13:37
Issue #5185 has been updated by Arnau Sanchez. +1, I just got bitten by this. Hash#merge returns a new object, so one should expect Set#merge to behave the same way (Principle of Least Surprise). Set#merge! and Set#update for in-places unions both sound good to me. ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not https://bugs.ruby-lang.org/issues/5185 Author: Thomas Sawyer Status: Open Priority: Normal Assignee: Category: lib Target version: 2.0.0 Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2012-03-26 19:34
Issue #5185 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to knu (Akinori MUSHA) I understand the problem, but I guess it is too late to fix it. Anyway, I'm assigning this to knu, the maintainer of lib/set.rb. -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not https://bugs.ruby-lang.org/issues/5185#change-25206 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: knu (Akinori MUSHA) Category: lib Target version: 2.0.0 Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2012-05-17 11:24
Issue #5185 has been updated by knu (Akinori MUSHA). I feel it's hard to change this by now since #merge is a library method (for subclasses) rather than just a user method, but I could add #update as an alias for #merge and then obsolete #merge which would eventually be end-of-life'd. ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not https://bugs.ruby-lang.org/issues/5185#change-26678 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: knu (Akinori MUSHA) Category: lib Target version: 2.0.0 Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2012-05-17 16:34
Issue #5185 has been updated by trans (Thomas Sawyer). Adding #update is a good idea. I would also add a warning to #merge stating that it's behaviour will change in a future version and to use #update instead. Then after a little while obsolete #merge altogether, but only for a bit, then bring it back with expected behaviour of producing new Set. I advocate a slightly accelerated time scale for this transition b/c if some people are making the mistake of assuming Set#merge works like Hash's already and finding out the hard way that it's not, then I think that adds some impetus to taking the fast track. ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not https://bugs.ruby-lang.org/issues/5185#change-26681 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: knu (Akinori MUSHA) Category: lib Target version: 2.0.0 Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2012-05-18 10:20
Issue #5185 has been updated by alexeymuranov (Alexey Muranov).
=begin
As the topic is surprising behavior of (({Set})) methods, i propose to
deprecate (({Set#+})) as an alias of (({Set#|})), and maybe use it later
for the symmetric difference.
Currently (({Set#+})) is one of a few (if not the only) use of (({#+}))
for an operation which is not injective in each of the arguments: for
sets (({a})), (({b})), (({c})), the equality (({a + b == a + c})) does
not imply (({b == c})).
I can open a new issue for this if there is some interest.
=end
----------------------------------------
Feature #5185: Set#merge acts in place but Hash#merge does not
https://bugs.ruby-lang.org/issues/5185#change-26699
Author: trans (Thomas Sawyer)
Status: Assigned
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: 2.0.0
Waste of brain cells to have to learn and recall they are different. The
expected method would be Set#merge!, Set#merge would return a new Set
instance.
OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2012-10-28 18:11
Issue #5185 has been updated by knu (Akinori MUSHA). Status changed from Assigned to Rejected On second thought recalling my original intention, I would say #update doesn't really fit for sets. The word "update" indicates that some data may be lost through an operation by overwriting, but Set#merge does not cause any data loss (in terms of the equality definition in Set) whereas Hash#update does. That's why I did not name it "update". As for Set#merge, I admit it wasn't the best choice when we had Hash#merge, but you can always use the "|" operator to avoid confusion. I'd also point out that there are not many examples where #merge is not destructive. In fact, the majority works destuctively. (simple grepping in ruby's source tree and some other gems showed that) I don't like Set#concat because the word concat[enate] usually means appending something at the bottom but Set has no sense of order. I don't like Set#union! either because the word "union" is a noun, not a verb that a bang method is usually derived from. ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not https://bugs.ruby-lang.org/issues/5185#change-31894 Author: trans (Thomas Sawyer) Status: Rejected Priority: Normal Assignee: knu (Akinori MUSHA) Category: lib Target version: 2.0.0 Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
on 2012-11-12 15:42
Issue #5185 has been updated by trans (Thomas Sawyer). Well, maybe #merge wasn't the best choice for Hash in the first place. Who knows. I only know that polymorphism is so incredibly useful in OOP, that it's a chink in the armor for the language when inconsistencies of this nature remain. ---------------------------------------- Feature #5185: Set#merge acts in place but Hash#merge does not https://bugs.ruby-lang.org/issues/5185#change-32816 Author: trans (Thomas Sawyer) Status: Rejected Priority: Normal Assignee: knu (Akinori MUSHA) Category: lib Target version: 2.0.0 Waste of brain cells to have to learn and recall they are different. The expected method would be Set#merge!, Set#merge would return a new Set instance. OTOH, why not Set#concat ? Or conversely, Array#merge ?
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.