title: Swift NumberOfRowsInSection Unexpected non-void return value in void function
body: <p>I'm trying to either show or not show my "NoPostsView" depending on my firebase database. </p>
  
  <p>That's my function for finding out if there are posts:</p>
  
  <pre><code>func checkIfPostsExists(YES: @escaping () -&gt; Void, NO: @escaping () -&gt; Void)
  {
       REF_POSTS.observeSingleEvent(of: .value, with:
       {
           (snapshot) in
           if snapshot.exists()
           {
               YES()
           }
           else
           {
               NO()
           }
       })
  }
  </code></pre>
  
  <p>And that's how I use it:</p>
  
  <pre><code>func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
  {
      checkIfPostsExists(YES:
      {
          if self.posts.count &lt;= 0
          {
              return 7 // ERROR IS IN THIS LINE
          }
          else if self.posts.count != 0
          {
              self.noPostsView.isHidden = true
          }
      })
      {
          self.noPostsView.isHidden = false
      }
      return posts.count
  }
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <blockquote>
    <p>Unexpected non-void return value in void function</p>
  </blockquote>
  
  <p>I'm pretty sure it's caused due to me returning 7 in that function but I can't seem to get my head around fixing the error.</p>