Not sure if you consider this an improvement or not, but using (map + compact) as a filter feels very clunky to me. I would use select, since that's what it's for, and then just grab the part of the result I care about:
arr.each_with_index.select { |a,i| a == 'x' }.map &:last