Hi --

On Thu, 21 Jun 2007, Alexander Presber wrote:

>
>>> The possibility to _flatten_ something requires it to be an Array-duck, 
>>> not an Enumerable-duck. That is why flatten is part of Array.
>>> Nobody should expect the result of Enumerable#select to be flattenable.
>> 
>> Well, that's what we're discussing :-)  I expect #select to return an
>> array, so it's flattenable.  But now I think we're going in circles.
>
> Why, of all possibities, an Array? Why not an Hash or any other class that 
> mixes in Enumerable?
> As I wanted to point out: The Array class is in no way a special Enumerable, 
> but it is treated special by being the return type of some (!) Enumerable 
> operations.
>
> See, not all Enumerables _are_ Arrays, it's  the other way around.
> It may not make much of a difference in every day coding, but if you don't 
> keep the two apart, then why not drop Enumerable alltogether and always mix 
> Array in instead?
> There should be a reason Enumerable was introduced as opposed to include it's 
> functionality in Array?

But its functionality is only in Array because Array mixes in
Enumerable.


David

-- 
* Books:
   RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242)
   RUBY FOR RAILS (http://www.manning.com/black)
* Ruby/Rails training
     & consulting:  Ruby Power and Light, LLC (http://www.rubypal.com)