title: Conversion of optional valued expressions to boolean
body: <p>This feels very basic. My apologies in advance. But consider the following four variations on the same theme:</p>
  
  <pre><code>var q : String? = nil
  
  if let z : String? = q {
      println("q is non-nil")
  } else {
      println("q is nil")
  }
  
  var zz : String? = nil
  if (zz) {
      println("zz is not nil")
  } else {
      println("zz is nil")
  }
  
  if let z : String? = nil {
      println("nil is non-nil")
  } else {
      println("nil is nil")
  }
  
  /*
  if (nil) {
      println("nil is non-nil")
  } else {
      println("nil is nil")
  }
  */
  </code></pre>
  
  <p>Naively, I think these should all behave identically. But the output is...</p>
  
  <pre><code>q is nil
  zz is nil
  nil is non-nil
  </code></pre>
  
  <p>If I uncomment the final form, I get...</p>
  
  <pre><code>Playground execution failed: error: &lt;REPL&gt;:57:5: error: type 'NilType' does not conform to protocol 'LogicValue'
  if (nil) {
  </code></pre>
  
  <p>What are the rules that explain when an optional expression can be treated as a boolean, with nil as false and {Some whatever} as true? Why does the third if statement print "nil is not nil" when it seems semantically identical to the others? Why is nil acceptable/convertable-to-LogicValue in an if statement when bound to a variable or in a let expression, but not when presented as a literal?</p>