When I call Array#-
it doesn't seems to call any comparison method on the strings I'm comparing:
class String
def <=>(v)
puts "#{self} <=> #{v}"
super(v)
end
def ==(v)
puts "#{self} == #{v}"
super(v)
end
def =~(v)
puts "#{self} =~ #{v}"
super(v)
end
def ===(v)
puts "#{self} == #{v}"
super(v)
end
def eql?(v)
puts "#{self}.eql? #{v}"
super(v)
end
def equal?(v)
puts "#{self}.equal? #{v}"
super(v)
end
def hash()
puts "#{self}.hash"
super
end
end
p %w{one two three} - %w{two}
It just returns:
["one", "three"]
So, what is Array#-
doing?
Also, I'm using Ruby 1.9.2p290. In 1.8.7 it seems to cause an infinite loop.