title: Argument altering messing up code
body: <p>The initial method's arguments <code>rec1</code> and <code>rec2</code> are altered when the second method is called, and <code>fourpoints</code> (an array of the two corners of a rectangle) is unexpectedly changed.</p>
  
  <pre><code>def rec_inter(rec1, rec2)
    foursides1 = []
    foursides2 = []
    fourpoints = rec1 + rec2
    p fourpoints
    points(rec1, foursides1)
    points(rec2, foursides2)
    crossing = foursides1 &amp; foursides2
    # want to  do -&gt; crossing &amp; fourpoints &lt;- to get intersections 
    p crossing
    p fourpoints #changes due to points method, how do I fix
  end
  def points(corners, rec)
    while corners[0][0] &lt;= corners[1][0]
      rec &lt;&lt; [corners[0][0], corners[0][1]]
      corners[0][0] = (corners[0][0] + 1)
    end
    while corners[0][1] &lt;= corners[1][1]
      rec &lt;&lt; [corners[1][0], corners[1][1]]
      corners[0][1] = (corners[1][0] + 1)
    end
    first = rec.flatten[0]
    while corners[1][0] &gt;= first
      rec &lt;&lt; [corners[1][0], corners[1][1]]
      corners[1][0] = corners[1][0] - 1
    end
    rec.uniq!
  end
  
  #rec1 &amp; rec2 == cross refernce
  rec_inter([[0, 0], [2, 1]], [[1, 0], [3, 1]])
  </code></pre>
  
  <p>Is there any way to store these values to a variable that isn't altered when the code is executed?</p>