From e8fc308315bfab764ceffe30243715c91153739a Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 30 Dec 2010 02:58:42 +0000 Subject: update doc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enum.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'enum.c') 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 nil, 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 -- cgit v1.2.3