This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.

each

        # Array.each

(from ruby core)
---
    array.each {|element| ... } -> self
    array.each -> Enumerator

---

Iterates over array elements.

When a block given, passes each successive array element to the block;
returns `self`:
    a = [:foo, 'bar', 2]
    a.each {|element|  puts "#{element.class} #{element}" }

Output:
    Symbol foo
    String bar
    Integer 2

Allows the array to be modified during iteration:
    a = [:foo, 'bar', 2]
    a.each {|element| puts element; a.clear if element.to_s.start_with?('b') }

Output:
    foo
    bar

When no block given, returns a new Enumerator:
    a = [:foo, 'bar', 2]
    e = a.each
    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.



      

This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.