title: Index out of range - error in function
body: <p>I have a function with 2 parameters - arrays of Int called Numbers and Numbers1. I want to multiply each element in Numbers on index "i" with each element in Numbers2 on the same index. Then I want to get a total sum of the results from the multiplying. When I call the function, it displays error - Index out of range. Code bellow:</p>
  
  <pre><code>var sum = Int()
  var Array = [Int]()
  var totalsum = Int()
  
  func prumerdanehopredmetu(Numbers:[Int], Numbers2:[Int]) -&gt; Int {
      for i in Numbers {
          sum = Numbers[i] * Numbers2[i]
          Array.insert(sum, at: 0)
      }
      totalsum = Array.reduce(0,+)
  
      return totalsum
  }
  
  prumerdanehopredmetu(Numbers: [1,2,3], Numbers2: [1,2,3])  //error
  </code></pre>
  
  <p>update:</p>
  
  <pre><code>for i in Numbers.indices
  </code></pre>
  
  <p>This worked.</p>