From: Gavin Sinclair Date: 2003-02-04T22:36:40+09:00 Subject: Re: Mismatch between documenation and implementation of Array#join() On Wednesday, February 5, 2003, 12:27:00 AM, Idan wrote: > Robert Klemme wrote: >>Hi, >> >>I'm wondering whether Array#join() has an error or the documentation is >>wrong. Documentation says: >>"Returns a string created by converting each element of the array to a >>string, separated by aSepString." This apparently does not include >>flatten(). But the behavior seems to be like flatten() was invoked before: >> >>With Ruby version 1.6.7: >> >>irb(main):015:0* a=[[0,1],[22,33]] >>[[0, 1], [22, 33]] >>irb(main):016:0> a.join(";") >>"0;1;22;33" >> >> >>I would have expected a.join(";") to have returned "01;2233" instead. >> > I seem to think it is the correct behaviour, Array#join is just invoked > in each of the subarrays as well (Recursive behaviour, just as #to_s > calls #to_s on all of the array members), however, your wish might be > fulfilled this way: [...] That's a bad argument for the "correct behaviour" POV. The doc doesn't specify recursive behaviour, so why do you expect it? If you don't expect it, isn't the behaviour wrong, no matter how simply it can be described? Array#to_s is actually specified (by 'ri') as returning 'arr.join', bringing us full circle. Gavin