title: Why can't the Swift compiler infer this closure's type?
body: <p>So I was writing code to differentiate multiple versions of my app:</p>
  
  <pre><code>static var jsonURLNL =  {
      if ProcessInfo.processInfo.environment["CONSUMER"] != nil {
          return URL(string: "consumerURL")!
      }
      return URL(string: "professionalURL")!
  }()
  </code></pre>
  
  <p>But I got a compiler error: </p>
  
  <blockquote>
    <p>Unable to infer complex closure return type; add explicit type to disambiguate</p>
  </blockquote>
  
  <p>Why can't the Swift compiler know that this will return a <code>URL</code>? I think it is fairly obvious in this case.</p>
  
  <p>My goal with this question is not to give critique on Xcode or Swift, it is to increase my knowledge of how the compiler infers types in Swift.</p>