Perhaps I was too hasty posting this? According to Matz about 6 years ago this didn't seem the right thing to do.
Hi,
In message "Re: [Bug #1893] Recursive Enumerable#join is surprising"
on Wed, 3 Mar 2010 00:57:26 +0900, Yusuke Endoh redmine@ruby-lang.org writes:
|I guess adding Enumerator#to_ary is a right solution.
I don't think so, supplying to_ary means that object can be considered
as an array, which is not always the case.
matz.
https://bugs.ruby-lang.org/issues/1893#note-7
Maybe things have changed since Ruby 1.9.2 on this issue? I've been reading through the other issue thread and I'm not sure it would be a bad thing. Most of the methods from Array are already defined and it would save a lot of to_a
calls from being written. It would make the following methods available on Enumerators.
Array.instance_methods - Enumerator.instance_methods
# => [:[], :[]=, :at, :fetch, :last, :concat, :<<, :push, :pop, :shift, :unshift, :insert, :each_index, :length, :empty?, :index, :rindex, :join, :reverse, :reverse!, :rotate, :rotate!, :sort!, :sort_by!, :collect!, :map!, :select!, :keep_if, :values_at, :delete, :delete_at, :delete_if, :reject!, :transpose, :replace, :clear, :fill, :slice, :slice!, :assoc, :rassoc, :+, :*, :-, :&, :|, :uniq, :uniq!, :compact, :compact!, :flatten, :flatten!, :shuffle!, :shuffle, :sample, :permutation, :combination, :repeated_permutation, :repeated_combination, :product, :bsearch, :pack]