title: Initializing an array with identical elements: `==` operator says arrays are the same, but they behave differently. Why?
body: <p>Here's my code:</p>
  
  <pre><code>a=["foo","foo","foo"]
  b=["foo"]*3
  a==b # =&gt; true
  
  a.each{|i| i&lt;&lt;"bar"}
  b.each{|i| i&lt;&lt;"bar"}
  a==b # =&gt; false
  </code></pre>
  
  <p>I get what I expect for <code>a</code>:</p>
  
  <pre><code>["foobar", "foobar", "foobar"]
  </code></pre>
  
  <p>but for <code>b</code>, I get this:</p>
  
  <pre><code>["foobarbarbar", "foobarbarbar", "foobarbarbar"]
  </code></pre>
  
  <ol>
  <li>Why is this happening? Is it a bug?</li>
  <li>Is there a way of filling an array with many identical strings that avoids this problem?</li>
  </ol>