title: Ruby: array is being passed by reference into function?
body: <p>I have a simple code below</p>
  
  <pre><code>    def testarray
        arr_tree = [1,2,3,4,5]
        (1..3).each do |index|
          abcde(arr_tree)
          puts arr_tree[0]
        end
      end
  
      def abcde(node_tree)
        node_tree[0] += 100
      end
  </code></pre>
  
  <p>So inside testarray function, I have an array <code>arr_tree</code> which is being passed to a function <code>abcde</code>. I change the value of the array inside <code>abcde</code> function and print array inside <code>testarray</code> I get the changed value here. So the output is</p>
  
  <pre><code>101
  201
  301
  </code></pre>
  
  <p>but I was expecting </p>
  
  <pre><code>1
  1
  1
  </code></pre>
  
  <p>Please explain why the results are like this? Also how can I achieve my expected result?</p>