title: How to conform custom class with optional properties to "hashable" protocol
body: <p>Suppose I have a base class "Person" that I want to add to a Set (List) and need to therefore conform to Hashable and Equatable:</p>
  
  <pre><code>class Person : Equatable, Hashable {
  let firstName: String
  let lastName: String
  var nickname: String?
  let dateOfBirth: NSDate
  var hashValue: Int {
      if let nickname = nickname {
          return firstName.hashValue ^
                 lastName.hashValue ^
                 nickname.hashValue ^
                 dateOfBirth.hashValue
      } else {
          return firstName.hashValue ^
                 lastName.hashValue ^
                 dateOfBirth.hashValue
      }
  
  }
  
  init (firstName: String, lastName: String, nickname: String, bornOn dateOfBirth: NSDate) {
      self.firstName = firstName
      self.lastName  = lastName
      self.nickname = nickname
      self.dateOfBirth = dateOfBirth
      }
  }
  
  func ==(lhs: Person, rhs: Person) -&gt; Bool {
      return
          lhs.firstName   == rhs.firstName    &amp;&amp;
          lhs.lastName    == rhs.lastName     &amp;&amp;
          lhs.nickname    == rhs.nickname     &amp;&amp;
          lhs.dateOfBirth == rhs.dateOfBirth
  }
  </code></pre>
  
  <p>This class has only a single optional property, which makes the dealing with the optional in the creation of the hashvalue fairly reasonable. What if there were 2 or more optional properties? I can see this getting out of hand quite quickly.</p>
  
  <p>How are optional properties generally dealt with when conforming an object to the hashable protocol?</p>