Project

General

Profile

Actions

Feature #11824

open

Add Enumerator#to_ary for added implicit behavior

Added by danielpclark (Daniel P. Clark) almost 6 years ago. Updated almost 6 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
Actions

Also available in: Atom PDF