This searches for the element given, and returns an array holding each index where it is found. If the element is not found, then an empty array is returned.
letters = [ :a, :b, :b, :c, :b ]
indexes = letters.indexes( :b ) // set to [ 1, 2, 4 ] indexes = letters.indexes( :a ) // set to [ 0 ] indexes = letters.indexes( :z ) // set to [ ]
.indexes()
Calling this with no element provided will return all of the arrays indexes.
letters = [ :a, :b, :b, :c, :b ]
indexes = letters.indexes() // set to: [ 0, 1, 2, 3, 4 ]