title: Conforming to Hashable protocol?
body: <p>I'm trying to make a dictionary with the key as a struct I've created and the value as an array of Ints. However, I keep getting the error:</p>
  
  <blockquote>
    <p>Type 'DateStruct' does not conform to protocol 'Hashable'</p>
  </blockquote>
  
  <p>I'm pretty sure I've implemented the necessary methods but for some reason it still doesn't work.</p>
  
  <p>Here's my struct with the implemented protocols:</p>
  
  <pre><code>struct DateStruct {
      var year: Int
      var month: Int
      var day: Int
  
      var hashValue: Int {
          return (year+month+day).hashValue
      }
  
      static func == (lhs: DateStruct, rhs: DateStruct) -&gt; Bool {
          return lhs.hashValue == rhs.hashValue
      }
  
      static func &lt; (lhs: DateStruct, rhs: DateStruct) -&gt; Bool {
          if (lhs.year &lt; rhs.year) {
              return true
          } else if (lhs.year &gt; rhs.year) {
              return false
          } else {
              if (lhs.month &lt; rhs.month) {
                  return true
              } else if (lhs.month &gt; rhs.month) {
                  return false
              } else {
                  if (lhs.day &lt; rhs.day) {
                      return true
                  } else {
                      return false
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Can anybody please explain to me why I'm still getting the error?</p>