From: Martin DeMello Date: 2005-02-05T19:09:12+09:00 Subject: Re: iteration the ruby way Navindra Umanee wrote: > Martin DeMello 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