If a is the array, I want a.index(a.max), but something more Ruby-like. It should be obvious, but I\'m having trouble finding the answer at so and
a
a.index(a.max)
Here is what I am thinking to answer this question :
a = (1..12).to_a.shuffle # => [8, 11, 9, 4, 10, 7, 3, 6, 5, 12, 1, 2] a.each_index.max_by { |i| a[i] } # => 9