title: Repeat function is not working for swift some parts of the code are not being called within the repeat
body: <pre><code>func rank(){
     am = 0
     print(amount)
     while am! &lt;= am - 1 {
          self.am += 1        
          print(am!)
          Firestore.firestore().collection(&quot;GeneralData&quot;).document(&quot;\(postID)&quot;).getDocument { 
              (document, err) in if let document = document, document.exists {
                  let data = document.data()
                  self.auser  = data![&quot;\(self.am!)&quot;] as? String
                  print(self.auser!)
                  if self.cuser == self.auser {
                      print(&quot;same usernames!&quot;)
                      self.rank = self.am
                  }
              }
          }
     }
  }
  </code></pre>
  <p>What I am trying to do is a ranking system which would find the users current rank, in firebase the data as follows:</p>
  <ol>
  <li><p>1: User1</p>
  </li>
  <li><p>2: User2</p>
  </li>
  <li><p>3: User3</p>
  </li>
  </ol>
  <p>etc... Basically I want to go through each number and call the correlated username which then is compared to the currents users username and whatever number was inputed to receive that usernmae will be the rank. Whats wrong is its for some reason not running the func which receives the data and is instead just repeating the am += 1 part. Any ideas of what I should do?</p>