Navindra Umanee <navindra / cs.mcgill.ca> wrote:
> Martin DeMello <martindemello / yahoo.com> wrote:
> > irb(main):006:0> b.inject(lambda {}) {|a,v| a.call; puts v; a = lambda { puts "-
> > --" }}
> 
> 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.

martin