title: Swift 3 Find the right index of an [Int] array with duplicate values
body: <p>i looking for a way to find the right index of an [int]-array with duplicate values. I want to recognize that the value in a loop has change. A loop-counter-varibale is not possible because the evaluation is in another thread.</p>
  
  <pre><code>var arrayInt = [1,2,2,3]
  var arrayIndex : Int?
  var currentStep = 0
  
  for i in arrayInt
  {
      arrayIndex = arrayInt.index(of: i)
      print("Index \(arrayIndex)")
      currentStep += 1 // Is not possible
  
      for numbers in 1...i{
  
           DispatchQueue.global().asyncAfter(deadline: .now() + .seconds(1 + currentStep)) {
               // prints always "4" becauses its at the executen time the value "4", which is plausible
               print("CurrentStep \(currentStep)")
           }
       }
  }
  //Prints:
  //Index Optional(0)
  //Index Optional(1)
  //Index Optional(1) // must be 2
  //Index Optional(3)
  </code></pre>
  
  <p>Solve by Gerriet:</p>
  
  <pre><code>var arrayInt = [1,2,2,3]
  var currentStep = 0
  
  for (currentStep,i) in arrayInt.enumerated(){
    for numbers in 1...i{
       DispatchQueue.global().asyncAfter(deadline: .now() + .seconds(1 + currentStep)) {
          print("CurrentStep \(currentStep)")
       }
    } 
  }
  //Prints:
  //CurrentStep Optional(0)
  //CurrentStep Optional(1)
  //CurrentStep Optional(2)
  //CurrentStep Optional(3)
  </code></pre>