On Thu, Jul 21, 2011 at 3:27 PM, CC Chen <dickyhide / gmail.com> wrote: > When I set an array k = [3,5,6,0,1,4,5,6,9,1] > > And I used the k.max can know the max value is 9 > > How do I get the number "8" (as k[8] = 9)?? > > What if you have an array like this [3,5,6,0,1,4,5,6,9,1,9] ? Do you want 8 or 10 or both? If you want both you could try something like this. per = [3,5,6,0,1,4,5,6,9,1,9] so_my_jacket, wont_open, now = [], per.max, per.size # because, (0...now).zip(per){|is_stuck, shut| so_my_jacket << is_stuck if shut==wont_open} p so_my_jacket #> [8, 10] OR k = [3,5,6,0,1,4,5,6,9,1,9] m,s,r = k.max,k.size,[] (0...s).zip(k){|x,i| r << x if i == m} p r #> [8, 10] Harry