title: Golang tutorial's slices exercise - my code does not work if index&value iteration is used
body: <p>I'm doing golang tutorial, and the <a href="https://tour.golang.org/moretypes/18" rel="nofollow noreferrer">very first exercise</a> is giving me a headache.</p>
  
  <p>The exercise in a nutshell wants me to dynamically create a array with dx*dy dimention.</p>
  
  <p>This is my function that receives <code>dx</code>, <code>dy</code> and returns <code>[dx][dy]uint8</code> array that works:</p>
  
  <pre class="lang-golang prettyprint-override"><code>func Pic(dx, dy int) [][]uint8 {
      resultArray := make([][]uint8, dx, dx)
      for i := range resultArray {
          fmt.Println(resultArray[i])
          resultArray[i] = make([]uint8, dy, dy)
          fmt.Println(resultArray)
          for j := range resultArray[i] {
              if (i+j)%30 &lt;= 15 {
                  resultArray[i][j] = uint8(255)
              }
          }
      }
      return resultArray
  }
  </code></pre>
  
  <p>However, this code which uses <code>for i, v := range x</code> does <strong>not</strong> work:</p>
  
  <pre class="lang-golang prettyprint-override"><code>func Pic(dx, dy int) [][]uint8 {
      resultArray := make([][]uint8, dx, dx)
      for i, ithRow := range resultArray {
          ithRow = make([]uint8, dy, dy)
          for j := range ithRow {
              if (i+j)%30 &lt;= 15 {
                  ithRow[j] = uint8(255)
              }
          }
      }
      return resultArray
  }
  </code></pre>
  
  <p>Does this not work because <code>ithRow</code> is a copy of <code>resultArray[i]</code>, but not reference of it? If so, why is it not reference of it(like, what is the benefit or use case of making it copied)?</p>