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\', \'.\', \'.\
A slight improvement over your each_with_index.map line
each_with_index.map
arr.map.with_index {|a, i| a == 'x' ? i : nil}.compact # => [0, 2, 6]