"Kristof Bastiaensen" <kristof / vleeuwen.org> 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. > For example the order of traversing a > Hash may differ for a different hash with the same elements. For this > reason the output of join for an enumerable is undefined. At least it is unpredictable. Even more so: order may change completely with each insertion: >> h=(0..5).inject({}){|h,i| h[i.to_s]=i;h} => {"0"=>0, "1"=>1, "2"=>2, "3"=>3, "4"=>4, "5"=>5} >> h.to_a => [["0", 0], ["1", 1], ["2", 2], ["3", 3], ["4", 4], ["5", 5]] >> h["6"]=6 => 6 >> h.to_a => [["6", 6], ["0", 0], ["1", 1], ["2", 2], ["3", 3], ["4", 4], ["5", 5]] Kind regards robert