ruby .map! or each for modifying an array in place
<p>I have the following:</p>

<pre><code>article_results.keys do |key|
  article_results[key].map! do |a|
    a[:filename] = c.filename
    a[:sitename] = c.site_name
    a
  end
end
</code></pre>

<p>As I want to add to each element of each array within the hash dynamically, but for some reason <code>a[:filename]</code> and <code>a[:sitename]</code> are blank when they are used. </p>

<p>So I want to know if I should be using <code>.each</code> instead.
Also I guess I'd like to know what's the main difference since they both can be used for side-effects.</p>

<p>I'm adding this as an extra fyi, I'm using ruby 1.8.7 so it would be nice to know how it differs between versions (1.8.7 - 1.9+) as well.</p>

<p>P.s. I know what the difference between <code>.each</code> and <code>.map</code> is, I'm asking specifically about <code>.map!</code>.</p>