[DOC] Tweaks for Array#each
This commit is contained in:
parent
18fb11aaa4
commit
818e20359f
Notes:
git
2024-09-11 17:15:57 +00:00
25
array.rb
25
array.rb
@ -1,11 +1,10 @@
|
|||||||
class Array
|
class Array
|
||||||
# call-seq:
|
# call-seq:
|
||||||
# array.each {|element| ... } -> self
|
# each {|element| ... } -> self
|
||||||
# array.each -> Enumerator
|
# each -> new_enumerator
|
||||||
#
|
#
|
||||||
# Iterates over array elements.
|
# With a block given, iterates over the elements of +self+,
|
||||||
#
|
# passing each element to the block;
|
||||||
# When a block given, passes each successive array element to the block;
|
|
||||||
# returns +self+:
|
# returns +self+:
|
||||||
#
|
#
|
||||||
# a = [:foo, 'bar', 2]
|
# a = [:foo, 'bar', 2]
|
||||||
@ -27,20 +26,10 @@ class Array
|
|||||||
# foo
|
# foo
|
||||||
# bar
|
# bar
|
||||||
#
|
#
|
||||||
# When no block given, returns a new Enumerator:
|
# With no block given, returns a new Enumerator.
|
||||||
# a = [:foo, 'bar', 2]
|
|
||||||
#
|
#
|
||||||
# e = a.each
|
# Related: see {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
|
||||||
# e # => #<Enumerator: [:foo, "bar", 2]:each>
|
|
||||||
# a1 = e.each {|element| puts "#{element.class} #{element}" }
|
|
||||||
#
|
|
||||||
# Output:
|
|
||||||
#
|
|
||||||
# Symbol foo
|
|
||||||
# String bar
|
|
||||||
# Integer 2
|
|
||||||
#
|
|
||||||
# Related: #each_index, #reverse_each.
|
|
||||||
def each
|
def each
|
||||||
Primitive.attr! :inline_block
|
Primitive.attr! :inline_block
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user