Martin DeMello <martindemello / yahoo.com> wrote: > > Actually, I prefer yours over Robert's because his leaves the last > > element dangling (could be useful of course). However, I don't think > > the lambda is at all necessary in your case, although I'm sure it > > could come in handy in an other situation. > > True, the lambda was overcomplicating it. Robert's version does work > better, though - the thing to note is that the last element is returned > by the inject method, so you can treat it as you like. In my case that means having to repeat code, which I don't want to do, but I can see Robert's being useful in a different situation. I really like the accumulator solution. The one I ended up with is a slight modification of the last one I posted: b.inject("") { |a, item| a += " | " if not a.empty? a += "#{item}" } except with more complex processing on item. I guess this is less efficient than a direct NilClass test, but I like the way it looks better. I think it's also easy to understand now and one of the shorter solutions. Thanks a lot for yours and everyone else's help on this thread. I would never have thought of this solution. Cheers, Navin.