[前][次][番号順一覧][スレッド一覧]

ruby-changes:25815

From: marcandre <ko1@a...>
Date: Tue, 27 Nov 2012 05:14:59 +0900 (JST)
Subject: [ruby-changes:25815] marcandRe: r37872 (trunk): * array.c: Fix rdoc for Array#delete [#7437]

marcandre	2012-11-27 05:14:49 +0900 (Tue, 27 Nov 2012)

  New Revision: 37872

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37872

  Log:
    * array.c: Fix rdoc for Array#delete [#7437]

  Modified files:
    trunk/array.c
    trunk/test/ruby/test_array.rb

Index: array.c
===================================================================
--- array.c	(revision 37871)
+++ array.c	(revision 37872)
@@ -2735,12 +2735,12 @@
 
 /*
  *  call-seq:
- *     ary.delete(obj)            -> obj or nil
- *     ary.delete(obj) { block }  -> obj or nil
+ *     ary.delete(obj)            -> item or nil
+ *     ary.delete(obj) { block }  -> item or result of block
  *
  *  Deletes all items from +self+ that are equal to +obj+.
  *
- *  If any items are found, returns +obj+, otherwise +nil+ is returned instead.
+ *  Returns the last deleted item, or +nil+ if no matching item is found.
  *
  *  If the optional code block is given, the result of the block is returned if
  *  the item is not found.  (To remove +nil+ elements and get an informative
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 37871)
+++ test/ruby/test_array.rb	(revision 37872)
@@ -598,6 +598,14 @@
     a = @cls[*('cab'..'cat').to_a]
     assert_equal(99, a.delete('cup') { 99 } )
     assert_equal(@cls[*('cab'..'cat').to_a], a)
+
+    o = Object.new
+    def o.==(other); true; end
+    o2 = Object.new
+    def o2.==(other); true; end
+    a = @cls[1, o, o2, 2]
+    assert_equal(o2, a.delete(42))
+    assert_equal([1, 2], a)
   end
 
   def test_delete_at

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]