class Set

Override #== to fix behavior where it seems to ignore overrides of Object#== or Object#eql? when comparing set elements. Note that we can't put these definitions inside a helper module, as we do for other methods, and include in the reopened Hash class. If we do this, the method is not used!

Public Instance Methods

==(set) click to toggle source
   # File lib/aquarium/extensions/set.rb
 7 def == set
 8   equal?(set) and return true
 9   set.is_a?(Set) && size == set.size or return false
10   ary = to_a
11   set.all? { |o| ary.include?(o) }
12 end
Also aliased as: eql?
eql?(set)
Alias for: ==
intersection_using_eql_comparison(other) click to toggle source

It seems that Set#& should work, but for some reason, it doesn't.

   # File lib/aquarium/extensions/set.rb
24 def intersection_using_eql_comparison other
25   first = dup
26   second = other.dup
27   first.size > second.size ? do_intersection(first, second) : do_intersection(second, first)
28 end
union_using_eql_comparison(other) click to toggle source

It seems that Set#| should work, but for some reason, it doesn't.

   # File lib/aquarium/extensions/set.rb
17 def union_using_eql_comparison other
18   first = dup
19   second = other.dup
20   first.size > second.size ? do_union(first, second) : do_union(second, first)
21 end