Project

General

Profile

Actions

Feature #11824

closed

Add Enumerator#to_ary for added implicit behavior

Added by danielpclark (Daniel P. Clark) over 8 years ago. Updated over 8 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:72160]

Description

Calling Enumerator#to_a many times can become a bit ugly in a code base. I propose these changes to Enumerator to allow implicit Array use of all Enumerators.

class Enumerator
  def to_ary
    to_a
  end

  def method_missing m, *a, &b
    return to_a.send(m, *a, &b) if Array.instance_methods.include? m
    super
  end
end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0