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!
# File lib/aquarium/extensions/set.rb, line 7 def == set equal?(set) and return true set.is_a?(Set) && size == set.size or return false ary = to_a set.all? { |o| ary.include?(o) } end
It seems that Set#& should work, but for some reason, it doesn’t.
# File lib/aquarium/extensions/set.rb, line 24 def intersection_using_eql_comparison other first = dup second = other.dup first.size > second.size ? do_intersection(first, second) : do_intersection(second, first) end
It seems that Set#| should work, but for some reason, it doesn’t.
# File lib/aquarium/extensions/set.rb, line 17 def union_using_eql_comparison other first = dup second = other.dup first.size > second.size ? do_union(first, second) : do_union(second, first) end