diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 16:28:52 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 16:28:52 +0000 |
commit | c98d3b58263c46eec0b9f5951b337086335e2536 (patch) | |
tree | 254ddf8c56ebcc04a82e5036eebaa73a0c792ec5 /lib/set.rb | |
parent | 3ed57a122727fda0a7ade91f828c7ba402ca0025 (diff) | |
download | ruby-c98d3b58263c46eec0b9f5951b337086335e2536.tar.gz |
Fix comparison methods of Set to check if `@hash` is actually comparable
This should fix comparison of rbtree backed SortedSet instances.
[Bug #12072]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/set.rb')
-rw-r--r-- | lib/set.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/set.rb b/lib/set.rb index caf80aa930..05eb3ffb2a 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -237,7 +237,7 @@ class Set # Returns true if the set is a superset of the given set. def superset?(set) case - when set.instance_of?(self.class) + when set.instance_of?(self.class) && @hash.respond_to?(:>=) @hash >= set.instance_variable_get(:@hash) when set.is_a?(Set) size >= set.size && set.all? { |o| include?(o) } @@ -250,7 +250,7 @@ class Set # Returns true if the set is a proper superset of the given set. def proper_superset?(set) case - when set.instance_of?(self.class) + when set.instance_of?(self.class) && @hash.respond_to?(:>) @hash > set.instance_variable_get(:@hash) when set.is_a?(Set) size > set.size && set.all? { |o| include?(o) } @@ -263,7 +263,7 @@ class Set # Returns true if the set is a subset of the given set. def subset?(set) case - when set.instance_of?(self.class) + when set.instance_of?(self.class) && @hash.respond_to?(:<=) @hash <= set.instance_variable_get(:@hash) when set.is_a?(Set) size <= set.size && all? { |o| set.include?(o) } @@ -276,7 +276,7 @@ class Set # Returns true if the set is a proper subset of the given set. def proper_subset?(set) case - when set.instance_of?(self.class) + when set.instance_of?(self.class) && @hash.respond_to?(:<) @hash < set.instance_variable_get(:@hash) when set.is_a?(Set) size < set.size && all? { |o| set.include?(o) } |