From: Joel VanderWerf Date: 2003-06-07T06:12:49+09:00 Subject: Re: [RCR] join block Michael Campbell wrote: >>Somehow, I would expect Array#join to pass two args to the block, >>like this: >> >> [1,2,3].join {|x,y| x < y ? " < " : " >= " } >> >> # ==> "1 < 2 < 3" > > > You lost me here. When iterating through the elements, what are x > and y; the current element in the array an the "next" one? What > value does "y" get then on the last element? > > I'd think even then, you'd get: > > "1 < 22 < 33" # no? I'm thinking the return value of the block should be used in the same way as the argument to #join would be used, as in: [1,2,3].join(" < ") (This is by analogy with sub("x","y") and sub("x") {"y"}.) If that's the case, then the block should only be called on successive pairs. But maybe my intuition about how block return values are used is wrong.