Ho una matrice di elementi. Se faccio un arr.max
otterrò il valore massimo. Ma mi piacerebbe avere l'indice dell'array. Come trovarlo in RubyCome trovare l'indice di un array che ha un valore massimo
Per esempio
a = [3,6,774,24,56,2,64,56,34]
=> [3, 6, 774, 24, 56, 2, 64, 56, 34]
>> a.max
a.max
=> 774
ho bisogno di sapere l'indice di quella che è 774
2
. Come posso farlo in Ruby?
Questa domanda equivale a parte della domanda posta a http://stackoverflow.com/questions/1656677/how-do-i-inde-a-geger-max-integer-in-an-array-for-ruby- e-return-the-indexed-p –