mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enumerator.c: [DOC] Enumerator#each arguments documentation [GH-388]
Patch by @kachick https://github.com/ruby/ruby/pull/388 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b8d053030e
commit
df3e4b8306
2 changed files with 36 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Sep 21 00:50:02 2013 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
|
* enumerator.c: [DOC] Enumerator#each arguments documentation [GH-388]
|
||||||
|
Patch by @kachick https://github.com/ruby/ruby/pull/388
|
||||||
|
|
||||||
Sat Sep 21 00:49:16 2013 Zachary Scott <e@zzak.io>
|
Sat Sep 21 00:49:16 2013 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* enum.c: [DOC] Enumerable#to_a accepts arguments [GH-388]
|
* enum.c: [DOC] Enumerable#to_a accepts arguments [GH-388]
|
||||||
|
|
34
enumerator.c
34
enumerator.c
|
@ -434,10 +434,38 @@ enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* enum.each {...}
|
* enum.each { |elm| block } -> obj
|
||||||
|
* enum.each -> enum
|
||||||
|
* enum.each(*appending_args) { |elm| block } -> obj
|
||||||
|
* enum.each(*appending_args) -> an_enumerator
|
||||||
*
|
*
|
||||||
* Iterates over the block according to how this Enumerable was constructed.
|
* Iterates over the block according to how this Enumerator was constructed.
|
||||||
* If no block is given, returns self.
|
* If no block and no arguments are given, returns self.
|
||||||
|
*
|
||||||
|
* === Examples
|
||||||
|
*
|
||||||
|
* "Hello, world!".scan(/\w+/) #=> ["Hello", "world"]
|
||||||
|
* "Hello, world!".to_enum(:scan, /\w+/).to_a #=> ["Hello", "world"]
|
||||||
|
* "Hello, world!".to_enum(:scan).each(/\w+/).to_a #=> ["Hello", "world"]
|
||||||
|
*
|
||||||
|
* obj = Object.new
|
||||||
|
*
|
||||||
|
* def obj.each_arg(a, b=:b, *rest)
|
||||||
|
* yield a
|
||||||
|
* yield b
|
||||||
|
* yield rest
|
||||||
|
* :method_returned
|
||||||
|
* end
|
||||||
|
*
|
||||||
|
* enum = obj.to_enum :each_arg, :a, :x
|
||||||
|
*
|
||||||
|
* enum.each.to_a #=> [:a, :x, []]
|
||||||
|
* enum.each.equal?(enum) #=> true
|
||||||
|
* enum.each { |elm| elm } #=> :method_returned
|
||||||
|
*
|
||||||
|
* enum.each(:y, :z).to_a #=> [:a, :x, [:y, :z]]
|
||||||
|
* enum.each(:y, :z).equal?(enum) #=> false
|
||||||
|
* enum.each(:y, :z) { |elm| elm } #=> :method_returned
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Reference in a new issue