==(other)
public
Returns true if two sets are equal. The equality of each couple of elements is defined according to
Object#eql?.
Set[1, 2] == Set[2, 1]
Set[1, 3, 5] == Set[1, 5]
Set['a', 'b', 'c'] == Set['a', 'c', 'b']
Set['a', 'b', 'c'] == ['a', 'c', 'b']
Show source
def ==(other)
if self.equal?(other)
true
elsif other.instance_of?(self.class)
@hash == other.instance_variable_get(:@hash)
elsif other.is_a?(Set) && self.size == other.size
other.all? { |o| @hash.include?(o) }
else
false
end
end