Subject: find index of first non zeo value in array
From: Josselin <josselin wanadoo.fr>
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