title: save initial state of array and reset in scala
body: <p>I am wondering what is the best way to save the initial state of an Array in scala so I can reset with initial values after manipulating a working copy. I would like to do something like this</p>
  
  <pre><code>val initialValue = Array(Array(1,2,3),Array(4,5,6))
  val workingCopy = initialValue.clone
  </code></pre>
  
  <p>The problem is that when I change values of workingCopy, I also change the values of initialValue.</p>
  
  <p>I also tried</p>
  
  <pre><code>val workingCopy = Array.fill(2,3)(0)
  Array.copy(initialValue,0,workingCopy,2)
  </code></pre>
  
  <p>But I get the same result.</p>
  
  <p>This holds even if i use <code>var</code> instead of <code>val</code> when defining the arrays. I think this shallow copy behavior might be caused by the nested Array structure, but I'm not sure how to deal with it.</p>