William James wrote:
> Robert Klemme wrote:
> > On 26.11.2006 14:59, 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
> >
> > Did we have a solution with #inject already?
>
> array.inject(0){|i,e| if e>0; break i else i+1 end}

array.inject(0){|i,e| break i if e>0; i+1 }