title: function with dataTask returning a value
body: <p>I wan't to check if my url statusCode equals to 200, I created a function returning a Boolean if the statusCode equals to 200, I'm using a dataTask, but I don't know how to return a value:</p>
  
  <pre><code>class func checkUrl(urlString: String) -&gt; Bool{
  
      let urlPath: String = urlString
      var url: NSURL = NSURL(string: urlPath)!
      var request: NSURLRequest = NSURLRequest(url: url as URL)
      var response: URLResponse?
  
      let session = Foundation.URLSession.shared
  
  
      var task = session.dataTask(with: request as URLRequest, completionHandler: {(data, response, error) in
          if let error = error {
              print(error)
          }
  
          if let data = data{
              print("data =\(data)")
          }
          if let response = response {
              print("url = \(response.url!)")
              print("response = \(response)")
              let httpResponse = response as! HTTPURLResponse
              print("response code = \(httpResponse.statusCode)")
  
              if httpResponse.statusCode == 200{
                  return true
              } else {
                  return false
              }
          }
      })
      task.resume()
  }
  </code></pre>
  
  <p>The returns in <code>if else</code> are returning an error:</p>
  
  <blockquote>
    <p>Unexpected non-void return value in void function</p>
  </blockquote>