From: "Pieter V." Date: 2009-06-12T02:53:51+09:00 Subject: Re: Idiomatic way to detect first/last iteration? That won't actually work if your array contains duplicate elements... On Thu, Jun 11, 2009 at 10:52 AM, Matthew K. Williams wrote: > I expect there's a better way to do this, but as a quick dash-off.... > > x=%w(the big fat cat) > > x.each do |y| > print "first " if (y==x.first) > print "last " if (y==x.last) > puts y > end > > -- > "... if you do follow your bliss you put yourself on a kind of > track that has been there all the while, waiting for you, and the life > that you ought to be living is the one you are living. When you can > see that, you begin to meet people who are in your field of bliss, and > they open doors to you. I say, follow your bliss and don't be afraid, > and doors will open where you didn't know they were going to be." -- > Joseph Campbell > >