summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-30 02:58:42 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-30 02:58:42 +0000
commite8fc308315bfab764ceffe30243715c91153739a (patch)
treec12c5803fb1e7394130c2fbe8cf8f2dcc556b5b5 /enum.c
parent03ac5a15d46f151f0048de20124fe7bfb4884819 (diff)
update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/enum.c b/enum.c
index eade8cb25a..b87659676c 100644
--- a/enum.c
+++ b/enum.c
@@ -616,7 +616,7 @@ partition_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
*
* If no block is given, an enumerator is returned instead.
*
- * (1..6).partition {|i| (i&1).zero?} #=> [[2, 4, 6], [1, 3, 5]]
+ * (1..6).partition {|v| v.even? } #=> [[2, 4, 6], [1, 3, 5]]
*
*/
@@ -714,6 +714,11 @@ first_i(VALUE i, VALUE *params, int argc, VALUE *argv)
* If the enumerable is empty, the first form returns <code>nil</code>, and the
* second form returns an empty array.
*
+ * %w[foo bar baz].first #=> "foo"
+ * %w[foo bar baz].first(2) #=> ["foo", "bar"]
+ * %w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
+ * [].first #=> nil
+ *
*/
static VALUE
@@ -1627,6 +1632,13 @@ enum_each_with_index(int argc, VALUE *argv, VALUE obj)
*
* If no block is given, an enumerator is returned instead.
*
+ * (1..3).reverse_each {|v| p v }
+ *
+ * produces:
+ *
+ * 3
+ * 2
+ * 1
*/
static VALUE
@@ -1671,13 +1683,17 @@ each_val_i(VALUE i, VALUE p, int argc, VALUE *argv)
* def each
* yield 1
* yield 1,2
+ * yield
* end
* end
- * Foo.new.each_entry{|o| print o, " -- "}
+ * Foo.new.each_entry{|o| p o }
*
* produces:
*
- * 1 -- [1, 2] --
+ * 1
+ * [1, 2]
+ * nil
+ *
*/
static VALUE