title: Mismatched types float64 and int
body: <p>I'm trying to create random grades and adding them to a <code>test_scores</code> array. Then calculate the average.</p>
  
  <p>This program:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "math/rand"
  )
  
  func main() {
      i := 0
      var test_scores [5]float64
      for i &lt; len(test_scores) {
          test_scores[i] = rand.Float64()
          i++
      }
      fmt.Println(test_scores)
  
      var total float64 = 0
      i = 0
      for i &lt; len(test_scores) {
          total += test_scores[i]
          i++
      }
      fmt.Println(total)
      fmt.Println(total / len(test_scores))
  }
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>main.go:24: invalid operation: total / 5 (mismatched types float64 and int)
  </code></pre>
  
  <p>This one works fine:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "math/rand"
  )
  
  func main() {
      i := 0
      var test_scores [5]float64
      for i &lt; len(test_scores) {
          test_scores[i] = rand.Float64()
          i++
      }
      fmt.Println(test_scores)
  
      var total float64 = 0
      i = 0
      for i &lt; len(test_scores) {
          total += test_scores[i]
          i++
      }
      fmt.Println(total)
      fmt.Println(total / 5)
  }
  </code></pre>
  
  <hr>
  
  <p>The only difference being that in the final line, I'm using a fixed <code>5</code> and on the non-working one, I'm using the <code>len(test_scores)</code> call.</p>
  
  <p><a href="http://golang.org/pkg/builtin/#len" rel="nofollow">Len</a> returns an integer as well, so what's up?</p>