title: Ruby Array concat versus + speed?
body: <p>I did small performance test of Ruby's array <code>concat()</code> vs <code>+</code> operation and <code>concat()</code> was way too fast.</p>
  
  <p>I however am not clear on why <code>concat()</code> is so fast?</p>
  
  <p>Can anyone help here?</p>
  
  <p>This is the code I used:</p>
  
  <pre><code>t = Time.now
  ar = []
  for i in 1..10000
  ar = ar + [4,5]
  end
  puts "Time for + " + (Time.now - t).to_s 
  
  
  t = Time.now
  ar = []
  for i in 1..10000
  ar.concat([4,5])
  end
  puts "Time for concat " + (Time.now - t).to_s 
  </code></pre>