# Ruby：如何找到最小數組元素的索引？

>> a = [2, 4, 10, 1, 13]
=> [2, 4, 10, 1, 13]
>> index_of_minimal_value_in_array = a.index(a.min)
=> 3


## 最佳答案

ary = [2,3,4,5,1]        # => [2,3,4,5,1]
ary.each_with_index.min  # => [1, 4]
# where 1 is the element and 4 is the index