Bug #118
SortedSet#inspect does not work with nested SortedSets
| Status: | Closed | Start date: | 06/09/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | - | |||
| ruby -v: |
Description
SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed
Associated revisions
History
Updated by Akinori MUSHA over 3 years ago
SortedSet cannot be put in a SortedSet because it is not comparable (unsortable). How do you define comparison between two (sorted) sets?
Updated by Anonymous over 3 years ago
Issue #118 has been updated by Akinori MUSHA. SortedSet cannot be put in a SortedSet because it is not comparable (unsortable). How do you define comparison between two (sorted) sets? ---------------------------------------- Bug #118: SortedSet#inspect does not work with nested SortedSets http://redmine.ruby-lang.org/issues/show/118 Author: Arthur Schreiber Status: Open Priority: Normal Assigned to: Akinori MUSHA Category: Target version: SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed ---------------------------------------- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account
Updated by Arthur Schreiber over 3 years ago
- File set.patch added
Here is a patch that makes SortedSet#add check that any object added to a SortedSet includes the Comparable module. It also extends the SortedSet documentation to make it more clear how SortedSet works.
Updated by Anonymous over 3 years ago
Issue #118 has been updated by Arthur Schreiber. File set.patch added Here is a patch that makes SortedSet#add check that any object added to a SortedSet includes the Comparable module. It also extends the SortedSet documentation to make it more clear how SortedSet works. ---------------------------------------- Bug #118: SortedSet#inspect does not work with nested SortedSets http://redmine.ruby-lang.org/issues/show/118 Author: Arthur Schreiber Status: Open Priority: Normal Assigned to: Akinori MUSHA Category: Target version: SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed ---------------------------------------- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account
Updated by Akinori MUSHA over 3 years ago
add() is not the only method that adds new elements to a set, but merge() also is. For merge(), you can omit the check when the given enumerable object is a SortedSet.
Updated by Anonymous over 3 years ago
Issue #118 has been updated by Akinori MUSHA. add() is not the only method that adds new elements to a set, but merge() also is. For merge(), you can omit the check when the given enumerable object is a SortedSet. ---------------------------------------- Bug #118: SortedSet#inspect does not work with nested SortedSets http://redmine.ruby-lang.org/issues/show/118 Author: Arthur Schreiber Status: Open Priority: Normal Assigned to: Akinori MUSHA Category: Target version: SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed ---------------------------------------- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account
Updated by Arthur Schreiber over 3 years ago
SortedSet#merge calls super (Set#merge), which in turn calls SortedSet#add for non-Set objects. So the only check needed is on SortedSet#add.
Updated by Anonymous over 3 years ago
Issue #118 has been updated by Arthur Schreiber. SortedSet#merge calls super (Set#merge), which in turn calls SortedSet#add for non-Set objects. So the only check needed is on SortedSet#add. ---------------------------------------- Bug #118: SortedSet#inspect does not work with nested SortedSets http://redmine.ruby-lang.org/issues/show/118 Author: Arthur Schreiber Status: Open Priority: Normal Assigned to: Akinori MUSHA Category: Target version: SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed ---------------------------------------- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account
Updated by Arthur Schreiber over 3 years ago
- File set.patch added
I attached a new patch for the set library. I changed Set#merge to only directly use the passed objects @hash instance variable when self and the passed object are instances of the same class. This prevents the addition of non-Comparable Objects when calling SortedSet#merge with a Set. I hope the patch is ok now.
Updated by Anonymous over 3 years ago
Issue #118 has been updated by Arthur Schreiber. File set.patch added I attached a new patch for the set library. I changed Set#merge to only directly use the passed objects @hash instance variable, when self and the passed object are instances of the same class. This prevents bugs when using a SortedSet in conjunction with the rbtree library. Additionally, It prevents the merging of non-Comparable Objects when calling SortedSet#merge with a Set. I hope the patch is ok now. ---------------------------------------- Bug #118: SortedSet#inspect does not work with nested SortedSets http://redmine.ruby-lang.org/issues/show/118 Author: Arthur Schreiber Status: Open Priority: Normal Assigned to: Akinori MUSHA Category: Target version: SortedSet["a", "b", SortedSet["c"]].inspect # => raises an ArgumentError: comparison of String with SortedSet failed ---------------------------------------- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account
Updated by Akinori MUSHA almost 3 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r23322.