title: Ruby array processing add an unexpected nil to the new array?
body: <p>New to Ruby (coming from Python) and try to experiment this exercise:
  (mixed the array items by taking first, last in rotating fashion)<br />
  Expected Output to be - [1, 7, 2, 6, 3, 5, 4]. But I did not expect 'nil' at the end... The orig. array can contain even or odd size of numbers.</p>
  <p>Can someone shed the light of this unexpected?  Thanks in advance.
  [Updates - re-write the example from Ruby Cookbook p.162  <em>Array</em> ]</p>
  <pre><code>nums = (1..7).to_a   # [1, 2, 3, 4, 5, 6, 7] 
  
  mixed = []
  #middle = nums.length / 2
  
  #index = 0
  
  until nums.empty?
    mixed &lt;&lt; nums.shift().  #get 1st element out
    mixed &lt;&lt; nums.pop()     #get last element out
    #index += 1
    
  end
  
  print mixed    # Got [1, 7, 2, 6, 3, 5, 4, nil]
  </code></pre>