title: Swift Optional type: how .None == nil works
body: <p>I'm trying to understand how does it work:</p>
  
  <pre><code>  1&gt; func returnNone() -&gt; String? { return .None }
    2&gt; returnNone() == nil
  $R0: Bool = true
    3&gt; returnNone() == .None
  $R1: Bool = true
  </code></pre>
  
  <p>Why <code>.None</code> is equal <code>nil</code>.</p>
  
  <p>I don't see anything about it in enum definition:</p>
  
  <pre><code>public enum Optional&lt;Wrapped&gt; : _Reflectable, NilLiteralConvertible {
      case None
      case Some(Wrapped)
      /// Construct a `nil` instance.
      public init()
      /// Construct a non-`nil` instance that stores `some`.
      public init(_ some: Wrapped)
      /// If `self == nil`, returns `nil`.  Otherwise, returns `f(self!)`.
      @warn_unused_result
      @rethrows public func map&lt;U&gt;(@noescape f: (Wrapped) throws -&gt; U) rethrows -&gt; U?
      /// Returns `nil` if `self` is nil, `f(self!)` otherwise.
      @warn_unused_result
      @rethrows public func flatMap&lt;U&gt;(@noescape f: (Wrapped) throws -&gt; U?) rethrows -&gt; U?
      /// Create an instance initialized with `nil`.
      public init(nilLiteral: ())
  }
  </code></pre>