From: Luis de la Rosa Date: 2007-04-03T13:54:17+09:00 Subject: Re: Last iteration condition Try this. It should print out "1,2,3,4,5,3,4" as desired. arr = [1, 2, 3, 4, 5, 3, 4] arr.each_with_index do |element, index| print element.to_s print "," unless arr.length == index + 1 end Cheers, Luis http://www.luisdelarosa.com On Apr 2, 2007, at 11:00 PM, Mike wrote: > Hi, > > How could I know that current iteration is the last in the series? > For example: > > [1, 2, 3, 4, 5, 3, 4].each do |element| > print element.to_s > print ',' if !LAST > end > > P.S. This is just an example. I don't want to use "join". My program > logic is much complicated than this example. > > Thank you. > >