title: Using type to define a multidimensional array in scala
body: <p>I'm trying to define a type for a matrix (two dimensional array). I have this:</p>
  
  <pre><code>scala&gt; type DMatrix[T] = Array[Array[T]]
  defined type alias DMatrix
  </code></pre>
  
  <p>and then I define de DMatrix:</p>
  
  <pre><code>scala&gt; def DMatrix = Array.ofDim[Double](2,2)
  DMatrix: Array[Array[Double]]
  </code></pre>
  
  <p>So far so good. The problem now is how to work with th DMatrix. I've tried some examples but nothing happens:</p>
  
  <pre><code>scala&gt; DMatrix(0)(0) = 1.0
  
  scala&gt; DMatrix
  res40: Array[Array[Double]] = Array(Array(0.0, 0.0), Array(0.0, 0.0))
  
  scala&gt; DMatrix(0)
  res41: Array[Double] = Array(0.0, 0.0)
  
  scala&gt; DMatrix(0) = Array(1.0,2.1)
  
  scala&gt; DMatrix(0)
  res43: Array[Double] = Array(0.0, 0.0)
  </code></pre>
  
  <p>so, the question is how to use this DMatrix type?</p>
  
  <p>thanks in advance</p>