title: swift - Optional to Bool Conversion Causes Error
body: <p>I'm having trouble checking if an optional exists or not in swift.</p>
  
  <pre><code>var myString:String? = "Hello"
  
  if myString {
      println(myString)
  }
  </code></pre>
  
  <p>When I use this code in a playground I get</p>
  
  <blockquote>
    <p>note: optional type 'String?' can not be used as a boolean; test for '!= nil' instead
    if myString {
       ^
       (        != nil)</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>error: type 'String?' does not conform to protocol 'BooleanType.Protocol'
    if myString </p>
  </blockquote>
  
  <p>The error suggests I use</p>
  
  <pre><code>myString != nil
  </code></pre>
  
  <p>but the documentation says this current code should be OK. Am I doing something wrong here?</p>