title: How to push items to ruby array using loop
body: <p>I am trying to create an array of dates using loop. But the loop is only pushing one date and when I query an array I see it's not an array, rather a list. Help.</p>
  
  <pre><code>date1 = '01-01-2019'.to_date
  dates = []
  count = 0
  repeat = 3
  
  while (count &lt; repeat)
   count += 1
   date2 = date1 + count.month
   dates &lt;&lt; date2
   puts dates
  end
  </code></pre>
  
  <p>Expected results should be <strong>[01-02-2019, 01-03-2019, 01-04-2019]</strong>.</p>
  
  <p>However, if I use rails console, all I get are the dates in a list. If I <strong><em>raise dates.inspect</em></strong> in controller, I only get <strong>01-02-2019</strong>.</p>
  
  <p>How can I fix this? </p>