title: Calculate a hashValue from a func in Swift
body: <p>I want to send a store a method address in a class, allowing the class to call that method. I want this class to be Hashable, and I want the hashValue to be calculated from the method such that 2 objects pointing to the same method have the same hashValue.</p>
  
  <p>Here is the class init that attempts to calculate the hashValue, but it fails. I think it hashes a pointer to the local variable.</p>
  
  <pre><code>typealias functionAlias = ((Double) -&gt; ())?
  
  class FunctionPointer: Hashable {
  private let functionPointer: functionAlias
  private let hash: Int
  
  init( functionPointer: functionAlias ) {
      self.functionPointer = functionPointer
      var f = functionPointer
      var h = 0
      withUnsafePointer(to: &amp;f, {
          ptr in
          h = ptr.hashValue
      })
      self.hash = h
      print("self.hash = \(self.hash)")
  }
  
  }
  </code></pre>
  
  <p>Thanks</p>