title: Two-dimensional array in Swift
body: <p>I get so confused about 2D arrays in Swift. Let me describe step by step. And would you please correct me if I am wrong.</p>
  
  <p>First of all; declaration of an empty array:</p>
  
  <pre><code>class test{
      var my2Darr = Int[][]()
  }
  </code></pre>
  
  <p>Secondly fill the array. (such as <code>my2Darr[i][j] = 0</code> where i, j are for-loop variables)</p>
  
  <pre><code>class test {
      var my2Darr = Int[][]()
      init() {
          for(var i:Int=0;i&lt;10;i++) {
              for(var j:Int=0;j&lt;10;j++) {
                  my2Darr[i][j]=18   /*  Is this correct?  */
              }
          }
      }
  }
  </code></pre>
  
  <p>And Lastly, Editing element of in array</p>
  
  <pre><code>class test {
      var my2Darr = Int[][]()
      init() {
          ....  //same as up code
      }
      func edit(number:Int,index:Int){
          my2Darr[index][index] = number
          // Is this correct? and What if index is bigger
          // than i or j... Can we control that like 
          if (my2Darr[i][j] == nil) { ...  }   */
      }
  }
  </code></pre>