How to find index of element in array ruby We have an array of 9 numbers a = [9,8,7,6,5,4,3,2,1] We put the index value at the variable position, for which we use the a.index method.The index of this value is what we want to get. position1 = a.index(8) We show the result puts position1