[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: join not in Enumerable

Eric Mahurin

5/23/2005 2:56:00 AM

--- "David A. Black" <dblack@wobblini.net> wrote:
> Size has the other problem too: being enumerable does not
> mean being
> measurable. For example:
>
> class C
> include Enumerable
> def each
> loop { yield rand(100) }
> end
> end
>
> It's meaningless to talk about the size of a C object -- but
> it's a
> perfectly legitimate enumerable.

I don't think an inifinite collection is a legitimate
enumerable. Since each is an infinite loop, none of the
Enumerable methods will necessarily escape that loop.
Enumerable#find (and friends) may return if it finds a match
since it probably breaks from the loop, but I don't think you
should depend on the implementation breaking from the loop (it
could simply record the first match).

I still think that any array method that is read-only and
operates in a single forward pass over an array would be good
to consider to go into Enumerable (Enumerable#sort* doesn't
meet those qualifications and I don't think it should have been
in there in the first place). But, even without doing this
enum.to_a.<array_method> should work just fine.




Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mai...