summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-14 08:39:34 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-14 08:39:34 +0000
commitf8c1ca18c91213c16708d565165c9e7a2420cf85 (patch)
tree801c38d82fce5d37fc09a57348fa7ff8962c6b10 /array.c
parent601c823734e725359024964f3b97795074ef4278 (diff)
* array.c (rb_ary_first): RDoc update from Daniel Berger
<djberg96@yahoo.com>. [ruby-core:06577]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/array.c b/array.c
index f16e0a663c..d14a49a716 100644
--- a/array.c
+++ b/array.c
@@ -715,12 +715,16 @@ rb_ary_at(ary, pos)
/*
* call-seq:
* array.first -> obj or nil
- *
- * Returns the first element of the array. If the array is empty,
- * returns <code>nil</code>.
- *
+ * array.first(n) -> an_array
+ *
+ * Returns the first element, or the first +n+ elements, of the array.
+ * If the array is empty, the first form returns <code>nil</code>, and the
+ * second form returns an empty array.
+ *
* a = [ "q", "r", "s", "t" ]
- * a.first #=> "q"
+ * a.first #=> "q"
+ * a.first(1) #=> ["q"]
+ * a.first(3) #=> ["q", "r", "s"]
*/
static VALUE