title: Swift: What do brackets around an if condition change?
body: <p>I try to get to grips with Swift and how to best separate nil and valid objects from optionals.</p>
  
  <p>I have this code:</p>
  
  <pre><code>var my AwesomeDict = [:]()
  ...
  ... (myAwesomeDict gets populated)
  ...
  let myOptionalObject:objectClass? = myAwesomeDict[key]
  if let myUnwrappedObject = myOptionalObject {
      ...
  } else {
      println("Sorry, object is nil")
  }
  </code></pre>
  
  <p>When I put brackets around the if clause (I feel it improves readability), XCode will flag the line with a compiler error: </p>
  
  <blockquote>
    <p>Pattern variable binding cannot appear in an expression</p>
  </blockquote>
  
  <p>What is different about</p>
  
  <pre><code>if (let myUnwrappedObject = myOptionalObject) {
  </code></pre>
  
  <p>from</p>
  
  <pre><code>if let myUnwrappedObject = myOptionalObject {
  </code></pre>
  
  <p>? Sadly, the documentation makes no mention of the effect of braces around if conditions. It seems I need to use the bracket-free version, but would like to become more enlightened about the reason.</p>