Existing methods

suggest change

If an iteration method such as each is called without a block, an Enumerator should be returned.

This can be done using the enum_for method:

def each
  return enum_for :each unless block_given?

  yield :x
  yield :y
  yield :z
end

This enables the programmer to compose Enumerable operations:

each.drop(2).map(&:upcase).first
# => :Z

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents