Given an array, how can I find all indices of elements those match a given condition?
For example, if I have:
arr = [\'x\', \'o\', \'x\', \'.\', \'.\
Ruby 1.9:
arr = ['x', 'o', 'x', '.', '.', 'o', 'x'] p arr.each_index.select{|i| arr[i] == 'x'} # =>[0, 2, 6]
Code