title: How to insert a new element in between all elements of a Ruby array?
body: <p>I have an Array and want to insert a new element in between all elements, someway like the <code>join</code> method. For example, I have</p>
  
  <pre><code>[1, [], "333"]
  </code></pre>
  
  <p>and what I need is</p>
  
  <pre><code>[1, {}, [], {}, "333"]
  </code></pre>
  
  <p>Note a new empty hash was inserted in between all elements.</p>
  
  <p>Edit:
  Currently what I have is:</p>
  
  <pre><code>irb(main):028:0&gt; a = [1, [], "333"]
  =&gt; [1, [], "333"]
  irb(main):029:0&gt; a = a.inject([]){|x, y| x &lt;&lt; y; x &lt;&lt; {}; x}
  =&gt; [1, {}, [], {}, "333", {}]
  irb(main):030:0&gt; a.pop
  =&gt; {}
  irb(main):031:0&gt; a
  =&gt; [1, {}, [], {}, "333"]
  irb(main):032:0&gt;
  </code></pre>
  
  <p>I want to know the best way.</p>