title: Swift Optional Patterns
body: <p>Swift optional pattern allows you to use <strong>case let</strong> like this:</p>
  
  <pre><code>var arrayOfOptional: [Int?] = [1, 2, nil, 4]
  
  for case let number? in arrayOfOptional {
    print("\(number)")
  }
  </code></pre>
  
  <p>What confuses me is the <strong>let number?</strong> syntax. In optional binding, the unwrapped version does not have <strong>?</strong>, but in case let, it does. How do you interpret this construct for it to make sense for you that number is unwrapped?</p>
  
  <p>Functionally, what's the difference between the two below:</p>
  
  <pre><code>if let x = someOptional {
    print(x)
  }
  </code></pre>
  
  <p>versus</p>
  
  <pre><code>if case let x? = someOptional {
    print(x)
  }
  </code></pre>