From: "David A. Black" Date: 2005-05-22T20:26:22+09:00 Subject: Re: join not in Enumerable Hi -- On Sun, 22 May 2005, Robert Klemme wrote: > > "Kristof Bastiaensen" schrieb im Newsbeitrag > news:pan.2005.05.22.09.53.41.174104@vleeuwen.org... >> On Sun, 22 May 2005 11:05:10 +0900, David A. Black wrote: >> >>>> Why is join, and perhaps even pack in Array and not in Enumerable? >>> >>> I guess to_a makes the conversion pretty easy, and Array tends to >>> serve as the "normalized" version of Enumerable in a lot of contexts. >>> I don't know if there's any other reason. >> >> I believe because join requires an ordered collection, and enumerables >> aren't guaranteed to be ordered. > > That would be my answer, too. As per my previous post, I don't think that matters for join, which is just a "dumb" string representation facility and won't care about order. Another related thought: Enumerables have this underlying numerical index, as reflected in Enumerable#each_with_index. Even hashes are, in that sense, "ordered": their elements are "indexed" from 0 up. 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. That's probably only tangentially related to #join, though. Mainly I think that #join is just a fancy #to_s, and orderedness isn't an issue. David -- David A. Black dblack@wobblini.net