Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Array#delete should return the last equal element in the array.

The currently released documentation is wrong.

The first released version of Ruby to exhibit this behavior is 1.8.7.
See http://bugs.ruby-lang.org/issues/7437
  • Loading branch information...
commit cc976da5ddce5e0fa8e95f2dd5237c02b1574fb9 1 parent 361d7d1
@BanzaiMan BanzaiMan authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 core/array/delete_spec.rb
View
14 core/array/delete_spec.rb
@@ -14,6 +14,20 @@ def x.==(other) 3 == other end
a.should == [1, 2, 4, 5]
end
+ ruby_version_is '1.8.7' ... '2.0' do
+ it "returns the last element in the array for which object is equal under #==" do
+ x = mock('delete')
+ y = mock('delete_more')
+ def x.==(other) 3 == other end
+ def y.==(other) 3 == other end
+
+ a = [1, 2, 3, y, 4, 3, 5, x]
+
+ ret = a.delete 3
+ ret.should == x
+ end
+ end
+
it "calculates equality correctly for reference values" do
a = ["foo", "bar", "foo", "quux", "foo"]
a.delete "foo"
Please sign in to comment.
Something went wrong with that request. Please try again.