Project

General

Profile

Feature #11824

Add Enumerator#to_ary for added implicit behavior

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

Status:
Feedback
Priority:
Normal
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

Also available in: Atom PDF