Ruby: Finding Indices of All Matches In An Array

I often need to get the indices of  all the elements that match a given condition. For example, an array contains the following contents

  A = [1,1,2,5,6,1,2,8]

I want to know the indices of all the ones present in that array. It is actually not that difficult to do so. By running the following you can achieve that

  puts A.each_index.select { |index| A[index] == 1} #=> [0,1,5]

This tutorial is based on http://stackoverflow.com/questions/13659696/ruby-how-to-find-all-indices-of-elements-that-match-a-given-condition