Feature #6596
Updated by sawa (Tsuyoshi Sawada) over 4 years ago
Hello 5 days ago, I submitted a pull request on Github that which provides a new method `Array#indexes`. It departs from `Array#index` for the array objects which is Array#indexes. I have fist edit the Array#index method in such a way that order it returns to return an array of indexes and not a single index (which is the single first occurrence it finds). I found it more logical but a user (trans) tells us that is relevant. The reason it could break the contract of Array#index so I decided to move it into Array#indexes. Eric (drbrain) tells me I should reasonning why I want to add this method is that ; it's just a point of view : I don't really understand why `Array#index` returns Array#index return a single index if the parameter is in the array several times. Examples ```ruby a = [1, 2, 3, 1] a.indexes(1) #=> Return : [0, 3] a.index(1) # => Return : 0 ``` In my opinion, it's not logical to return only a single index since `1` really logical, 1 is in the array twice. twice Moreover, this pull request doesn't beak anything because we don't edit the Array#index method so programms which were created with previous version of Ruby will work. I hope my post is complete. Have a nice day.