I'm trying to find the indexes where a specific string is located in a multidimensional array in Ruby. I'm using the following code.
array = [['x', 'x',' x','x'], ['x', 'S',' ','x'], ['x', 'x','x','S']] array.index(array.detect{|aa| aa.include?('S')} However, this only returns 1 (the first index). Does anyone know how I can alter this command to return all the indexes where the pattern is present? This example should return 1 and 2.