From: Park Heesob Date: 2006-11-27T00:52:22+09:00 Subject: Re: find index of first non zeo value in array Hi, >From: Josselin >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: find index of first non zeo value in array >Date: Sun, 26 Nov 2006 23:00:10 +0900 > >with : >array = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, >0, 0, 0, 0] > >I wrote : >array.index(array.detect {|x| x > 0}) => 15 > >is there a better and simpler way to do it ? >thanks > >joss > > How about this: array.index((array-[0])[0]) Regards, Park Heesob _________________________________________________________________ Don't just search. Find. Check out the new MSN Search! http://search.msn.com/