diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-10 10:25:44 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-10 10:25:44 +0000 |
commit | c04ad1d7e4ec54781b2eb9b07d4eaf7d4cd21c44 (patch) | |
tree | 379bc741e9156243b5d4f79677b9e4f73b7d791e | |
parent | 7132a4f9798eada290b3bd22184ca7e43c551ccf (diff) | |
download | ruby-c04ad1d7e4ec54781b2eb9b07d4eaf7d4cd21c44.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | array.c | 20 |
2 files changed, 19 insertions, 9 deletions
@@ -1,3 +1,11 @@ +Thu Apr 10 19:23:55 2008 Akinori MUSHA <knu@iDaemons.org> + + * 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@fsij.org> * marshal.c (w_object): TYPE_USERDEF assigns id for ivars first. @@ -498,10 +498,14 @@ rb_ary_pop(VALUE ary) /* * 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 @@ rb_ary_shift(VALUE ary) /* * 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,13 +1767,7 @@ rb_ary_delete_at_m(VALUE ary, VALUE pos) * * 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: - * - * def slice!(*args) - * result = self[*args] - * self[*args] = nil - * result - * end + * <code>nil</code> if the index is out of range. * * a = [ "a", "b", "c" ] * a.slice!(1) #=> "b" |