From: nobu.nokada@... Date: 2003-05-30T13:08:04+09:00 Subject: Re: Iteration - last detection Hi, At Fri, 30 May 2003 07:58:35 +0900, dblack@superlink.net wrote: > OK, as penance for clouding the issue with the mythical > Enumerable#size, I feel morally obliged to write a real version :-) > I'm not sure how horrible this is. Very, I suspect. But anyway, > another possibility: > > module Enumerable > def each_with_last > n = -1 > each { n += 1 } > each_with_index {|e,i| yield(e, i == n)} > end > end Enumerable doesn't guarantee multiple iterations. e.g. IO. -- Nobu Nakada