On Thu, 2002-07-11 at 04:55, David Alan Black wrote: > I like each_with_nindex too... but show me an example of this comma > problem that isn't better solved with #join and I'll put the price of > a beer in your Paypal account :-) what i used to do: q = '' arr.each do |x| q << 'junk' << x << 'morejunk' << ',' end q.chomp!(',') what i now do: q = '' arr.each_with_nindex do |x, n| q << 'junk' << x << 'morejunk' q << ',' if n != -1 end how do you do it with join? note: how i used to do it is probably a tad faster actually ~transami On Thu, 2002-07-11 at 04:55, David Alan Black wrote: > Hi -- > > On Thu, 11 Jul 2002, Tom Sawyer wrote: > > > each_with_nindex, rocking! i'll throw that in my library, for sure. > > > > it's really nice for building strings with dividers, e.g. "a,b,c" in > > order to keep that last comma from getting appended to the end. > > I like each_with_nindex too... but show me an example of this comma > problem that isn't better solved with #join and I'll put the price of > a beer in your Paypal account :-) > > > David > > -- > David Alan Black > home: dblack / candle.superlink.net > work: blackdav / shu.edu > Web: http://pirate.shu.edu/~blackdav > > -- ~transami "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin