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

ruby-changes:4459

From: ko1@a...
Date: Thu, 10 Apr 2008 19:26:09 +0900 (JST)
Subject: [ruby-changes:4459] knu - Ruby:r15950 (trunk): * array.c (rb_ary_pop_m, rb_ary_shift_m): Update documents for

knu	2008-04-10 19:25:44 +0900 (Thu, 10 Apr 2008)

  New Revision: 15950

  Modified files:
    trunk/ChangeLog
    trunk/array.c

  Log:
    * array.c (rb_ary_pop_m, rb_ary_shift_m): Update documents for
      #pop() and #shift().
    
    * array.c (rb_ary_slice_bang): Update document.  Assigning
      array[*args]= nil no longer removes elements.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/array.c?r1=15950&r2=15949&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15950&r2=15949&diff_format=u

Index: array.c
===================================================================
--- array.c	(revision 15949)
+++ array.c	(revision 15950)
@@ -498,10 +498,14 @@
 
 /*
  *  call-seq:
- *     array.pop  -> obj or nil
+ *     array.pop    -> obj or nil
+ *     array.pop(n) -> array
  *  
  *  Removes the last element from <i>self</i> and returns it, or
  *  <code>nil</code> if the array is empty.
+ *
+ *  If a number _n_ is given, returns an array of the last n elements
+ *  (or less) just like <code>array.slice(-n, n)</code> does.
  *     
  *     a = [ "a", "b", "c", "d" ]
  *     a.pop     #=> "d"
@@ -549,11 +553,15 @@
 
 /*
  *  call-seq:
- *     array.shift   ->   obj or nil
+ *     array.shift    -> obj or nil
+ *     array.shift(n) -> array
  *  
  *  Returns the first element of <i>self</i> and removes it (shifting all
  *  other elements down by one). Returns <code>nil</code> if the array
  *  is empty.
+ *
+ *  If a number _n_ is given, returns an array of the first n elements
+ *  (or less) just like <code>array.slice(0, n)</code> does.
  *     
  *     args = [ "-m", "-q", "filename" ]
  *     args.shift     #=> "-m"
@@ -1759,14 +1767,8 @@
  *  
  *  Deletes the element(s) given by an index (optionally with a length)
  *  or by a range. Returns the deleted object, subarray, or
- *  <code>nil</code> if the index is out of range. Equivalent to:
+ *  <code>nil</code> if the index is out of range.
  *     
- *     def slice!(*args)
- *       result = self[*args]
- *       self[*args] = nil
- *       result
- *     end
- *     
  *     a = [ "a", "b", "c" ]
  *     a.slice!(1)     #=> "b"
  *     a               #=> ["a", "c"]
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15949)
+++ ChangeLog	(revision 15950)
@@ -1,3 +1,11 @@
+Thu Apr 10 19:23:55 2008  Akinori MUSHA  <knu@i...>
+
+	* array.c (rb_ary_pop_m, rb_ary_shift_m): Update documents for
+	  #pop() and #shift().
+
+	* array.c (rb_ary_slice_bang): Update document.  Assigning
+	  array[*args]= nil no longer removes elements.
+
 Thu Apr 10 16:58:44 2008  Tanaka Akira  <akr@f...>
 
 	* marshal.c (w_object): TYPE_USERDEF assigns id for ivars first.

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

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