其实很简单Ruby的Array类自带了min方法可以求出最小值,然后调用Array的index方法传入元素值就可以求出下标 a = [1, 2, 3, 4, 5, 6] theMin = a.min #=> 1 theIndex = a.index(a.min) #=> 0