Project

General

Profile

Actions

Bug #16690

closed

[BUG] Set of sets: containing set no longer believes member set is a member after mutating its member set

Added by keithyjohnson (Keith Johnson) about 4 years ago. Updated about 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:97453]

Description

Please correct me if I'm wrong but I expected that when mutating a member set of a containing set, that that mutated member set, would still be considered a member of the containing set. But after merging another set into the member set, the containing set no longer believes it to be a member. I was surprised by this, but if that is expected behavior, please let me know! Also, please let me know if you have any more questions.

[1] pry(#<Clustering>)> clusters.class
=> Set
[2] pry(#<Clustering>)> smaller_cluster.class
=> Set
[3] pry(#<Clustering>)> larger_cluster.class
=> Set
[4] pry(#<Clustering>)> x = larger_cluster.object_id
=> 70237123254460
[5] pry(#<Clustering>)> clusters.member?(larger_cluster)
=> true
[6] pry(#<Clustering>)> larger_cluster.merge(smaller_cluster)
=> #<Set: {387, 92}>
[7] pry(#<Clustering>)> larger_cluster.object_id == x
=> true
[8] pry(#<Clustering>)> clusters.member?(larger_cluster)
=> false
[9] pry(#<Clustering>)> clusters.map(&:object_id).include?(larger_cluster.object_id)
=> true
[10] pry(#<Clustering>)> RUBY_VERSION
=> "2.3.0"
Actions

Also available in: Atom PDF

Like0
Like0Like0