summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-07 17:15:49 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-07 17:15:49 +0000
commit6720c0aeeba1921010ae96325b1d4caba33794c5 (patch)
tree11423ab11c071d84bdb832542b281692a3db6240 /array.c
parentbceb8569866439e832d0500aa1bf4ad2b8e36be8 (diff)
* array.c: [DOC] Add note about negative indices in Array overview
By @ckaenzig [Fixes GH-427] https://github.com/ruby/ruby/pull/427 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/array.c b/array.c
index 1a71f1b459..5d01fdb551 100644
--- a/array.c
+++ b/array.c
@@ -5404,7 +5404,8 @@ rb_ary_drop_while(VALUE ary)
*
* 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)
* 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
*