Project

General

Profile

Bug #140 ยป set_equal_value.patch

NoKarma (Arthur Schreiber), 06/11/2008 09:01 AM

View differences:

lib/set.rb (Arbeitskopie)
314 314

  
315 315
  # Returns true if two sets are equal.  The equality of each couple
316 316
  # of elements is defined according to Object#eql?.
317
  def ==(set)
318
    equal?(set) and return true
319

  
320
    set.is_a?(Set) && size == set.size or return false
321

  
322
    hash = @hash.dup
323
    set.all? { |o| hash.include?(o) }
317
  def ==(other)
318
    if self.equal?(other)
319
      true
320
    elsif other.instance_of?(self.class)
321
      @hash == other.instance_variable_get(:@hash)
322
    elsif other.is_a?(Set) && self.size == other.size
323
      other.all? { |o| @hash.include?(o) }
324
    else
325
      false
326
    end
324 327
  end
325 328

  
326 329
  def hash	# :nodoc: