From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-06-09T19:59:23+09:00 Subject: Re: [RCR] join block On Mon, 09 Jun 2003 10:14:00 +0000, Martin DeMello wrote: > Simon Strandgaard <0bz63fz3m1qt3001@sneakemail.com> wrote: >> >> So far I cannot think of any cases where I need to "join-pairs into a >> string". Can you show some more examples in order to convince me, that this >> actualy is usable ? :-) > > "{" << [1,2,3,"a","b",5,"c"].join {|x,y| > (x.type == y.type) ? "," : "} {" << "}" > > #=> {1,2,3} {a,b} {5} {c} > > words.join {|x,y| (x[-1] == ?.) ? "\n" : " "} OK.. You win, I loose. > 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'. Everytime I debug or do CGI, I use 'cjoin'. I have never been in a situation where 'pjoin' could be useful for me. What is your thoughts on what is most often used ? -- Simon Strandgaard