From: x1 Date: 2006-11-28T16:21:39+09:00 Subject: Re: find index of first non zeo value in array # uber_nasty_for_laughs.rb array.to_s.split(/[1-9]/)[0].length On 11/26/06, Josselin wrote: > 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 > > >