Class Set
In: lib/aquarium/extensions/set.rb
Parent: Object

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!

Methods

Public Instance methods

[Source]

    # File lib/aquarium/extensions/set.rb, line 7
 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
eql?(set)

Alias for #==

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

[Source]

    # File lib/aquarium/extensions/set.rb, line 24
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

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

[Source]

    # File lib/aquarium/extensions/set.rb, line 17
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

[Validate]