D
Daniel Berger
Hi all,
In messing around with Array#delete I think I've uncovered a problem.
Consider this example:
class Foo
def ==(other)
$array.clear
false
end
end
arr = [1, 2, 3]
arr << Foo.new
Arr << 'b'
$array = arr
arr.delete('a')
p arr # => []
p $array # => []
That's what I would expect. It did the comparison, and called the
Foo#== method, which in turn cleared the receiver.
But if you do this instead:
arr.delete(1)
You end up with:
[nil, nil, #<Foo:0x2865ff4>]
[nil, nil, #<Foo:0x2865ff4>]
What's happening?
Thanks,
Dan
In messing around with Array#delete I think I've uncovered a problem.
Consider this example:
class Foo
def ==(other)
$array.clear
false
end
end
arr = [1, 2, 3]
arr << Foo.new
Arr << 'b'
$array = arr
arr.delete('a')
p arr # => []
p $array # => []
That's what I would expect. It did the comparison, and called the
Foo#== method, which in turn cleared the receiver.
But if you do this instead:
arr.delete(1)
You end up with:
[nil, nil, #<Foo:0x2865ff4>]
[nil, nil, #<Foo:0x2865ff4>]
What's happening?
Thanks,
Dan