[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/22/2005 1:59:00 PM

--- "David A. Black" <dblack@wobblini.net> wrote:
> I have to say, though, that I think #each_with_index should
> be removed
> from Enumerable and pushed down to the classes that mix it in
> (similarly to #each_index). But I suppose as long as they
> are called
> "enumerable" they are in some sense associated with a
> numerical index.

Unfortunately for Hash, this can cause confusion to what an
"index" is. If it weren't for an already existing Hash#index
(which gets a key), I would suggest it be brought over from
Array to Enumerable.

I do tend to think that many of the Array methods should be
brought over to Enumerable. You could bring over just about
any one that is non-modifying and operates sequentially forward
on the array, but you may also restrict the ones related to an
"index":

*, +, <=>, ==, assoc, compact, concat, empty?, eql?, first,
flatten, hash, join, last, length, nitems, pack, rassoc, size,
to_s, uniq

And if you don't care about the "index" confusion in hash, you
could get these:

[], at, fetch, index, slice, values_at





Discover Yahoo!
Find restaurants, movies, travel and more fun for the weekend. Check it out!
http://discover.yahoo.com/we...



3 Answers

dblack

5/22/2005 2:18:00 PM

0

Ara.T.Howard

5/22/2005 2:51:00 PM

0

dblack

5/22/2005 3:12:00 PM

0