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

ruby-changes:31491

From: zzak <ko1@a...>
Date: Fri, 8 Nov 2013 02:15:54 +0900 (JST)
Subject: [ruby-changes:31491] zzak:r43570 (trunk): * array.c: [DOC] Add note about negative indices in Array overview

zzak	2013-11-08 02:15:49 +0900 (Fri, 08 Nov 2013)

  New Revision: 43570

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

  Log:
    * array.c: [DOC] Add note about negative indices in Array overview
      By @ckaenzig [Fixes GH-427] https://github.com/ruby/ruby/pull/427

  Modified files:
    trunk/ChangeLog
    trunk/array.c
Index: array.c
===================================================================
--- array.c	(revision 43569)
+++ array.c	(revision 43570)
@@ -5404,7 +5404,8 @@ rb_ary_drop_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L5404
  *
  *  Elements in an array can be retrieved using the Array#[] method.  It can
  *  take a single integer argument (a numeric index), a pair of arguments
- *  (start and length) or a range.
+ *  (start and length) or a range. Negative indices start counting from the end,
+ *  with -1 being the last element.
  *
  *     arr = [1, 2, 3, 4, 5, 6]
  *     arr[2]    #=> 3
@@ -5412,6 +5413,7 @@ rb_ary_drop_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L5413
  *     arr[-3]   #=> 4
  *     arr[2, 3] #=> [3, 4, 5]
  *     arr[1..4] #=> [2, 3, 4, 5]
+ *     arr[1..-3] #=> [2, 3, 4]
  *
  *  Another way to access a particular array element is by using the #at method
  *
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43569)
+++ ChangeLog	(revision 43570)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov  8 02:14:37 2013  Zachary Scott  <e@z...>
+
+	* array.c: [DOC] Add note about negative indices in Array overview
+	  By @ckaenzig [Fixes GH-427] https://github.com/ruby/ruby/pull/427
+
 Fri Nov  8 02:09:12 2013  Zachary Scott  <e@z...>
 
 	* lib/csv.rb: [DOC] Fix typo in CSV.parse_line by @funky-bibimbap

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

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