title: Map an array modifying only elements matching a certain condition
body: <p>In Ruby, what is the most expressive way to map an array in such a way that certain elements are modified <em>and the others left untouched</em>?</p>
  
  <p>This is a straight-forward way to do it:</p>
  
  <pre><code>old_a = ["a", "b", "c"]                         # ["a", "b", "c"]
  new_a = old_a.map { |x| (x=="b" ? x+"!" : x) }  # ["a", "b!", "c"]
  </code></pre>
  
  <p>Omitting the "leave-alone" case of course if not enough:</p>
  
  <pre><code>new_a = old_a.map { |x| x+"!" if x=="b" }       # [nil, "b!", nil]
  </code></pre>
  
  <p>What I would like is something like this:</p>
  
  <pre><code>new_a = old_a.map_modifying_only_elements_where (Proc.new {|x| x == "b"}) 
          do |y|
            y + "!"
          end
  # ["a", "b!", "c"]
  </code></pre>
  
  <p>Is there some nice way to do this in Ruby (or maybe Rails has some kind of convenience method that I haven't found yet)?</p>
  
  <hr>
  
  <p>Thanks everybody for replying. While you collectively convinced me that it's best to just use <code>map</code> with the ternary operator, some of you posted very interesting answers!</p>