From: Martin DeMello Date: 2005-02-05T07:50:16+09:00 Subject: Re: iteration the ruby way David A. Black wrote: > If your enumerable object has a size method, you can do: > > bottom_items.each_with_index do |item,i| > do_something_with(...) > unless i == bottom_items.size - 1 > ... > end > end > > or something similar with #each_index. And if it doesn't, this approach should work: irb(main):005:0> b = [1,2,3,4,5] => [1, 2, 3, 4, 5] irb(main):006:0> b.inject(lambda {}) {|a,v| a.call; puts v; a = lambda { puts "- --" }} martin p.s. who'd have thunk it