title: Calculating the Average of Arguments
body: <p>I'm working through "The Swift Programming Language" and the associated playground file. </p>
  
  <p>I have one section where I am asked: 
  Write a function that calculates the average of its arguments.</p>
  
  <p>Given the context, this is my solution</p>
  
  <pre><code>func averageOf(numbers: Int...) -&gt; Int {
      var sum = 0
      var countOfNumbers = 0
      for number in numbers {
          sum += number
          countOfNumbers += 1
      }
      var result: Double = Double(sum) / Double(countOfNumbers)
      return result
  }
  
  averageOf()
  averageOf(10, 20, 30)
  </code></pre>
  
  <p>As you can see I had to call the result as a Double (thats the sum / countOfNumbers).</p>
  
  <p>However, I can't return result in this case because I get an error about converting return expression of type "Double".</p>
  
  <p>So then I tried to return Double(result) without success.</p>
  
  <p>Why does this not work and how can I best understand what I am doing wrong here? </p>