diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-30 02:58:42 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-30 02:58:42 +0000 |
commit | e8fc308315bfab764ceffe30243715c91153739a (patch) | |
tree | c12c5803fb1e7394130c2fbe8cf8f2dcc556b5b5 /enum.c | |
parent | 03ac5a15d46f151f0048de20124fe7bfb4884819 (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.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -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 |