From: Warren Brown Date: 2003-06-10T04:52:13+09:00 Subject: Re: [RCR] join block Simon, >> As for the block working on individual >> elements, that's map's job. > > cjoin = collect-join > pjoin = pair-join > > I still think 'cjoin' is much more often used > in practice than 'pjoin'. I use 'puts foo.join("\n")' quite often too, but I wouldn't suggest adding a puts_join() method to the language - even though it wouldn't break any existing code :o) It's not a question of which one is used more often, it is a question of orthagonality. Array#join's job is to insert a string between pairs of adjacent elements. Array#map()'s job is to process elements one at a time and collect the output into a new array. If Array#join were to take a block, the block would need to be used to generate the string to insert between adjacent elements. That is why Joel suggested the '[1,2,3].join {|x,y| x < y ? " < " : " >= " }' methodology. I don't really think that it is worth adding this to the language, especially since there is a problem with the new Array#join being able to take both a string argument and a (conflicting) block. I think that this is just another case of a request for a change to the language, someone pointing out that the change is not a good idea but offering an alternative change that does make sense. I hope this helps clarify things... - Warren Brown