The Hashable now want to use protocol instead of hashValue but I can't figure it outNSObject is Hashable but a protocol that adopts NSObject is not?CFString doesn't conform to protocol Hashable?Why can't I call hash() on an apparently hashable method of an unhashable instance?How to handle hash collisions for Dictionaries in SwiftCreating a protocol that represents hashable objects that can be on or offperformance considerations of hashValue in swift protocol HashableHashable protocol for a protocolConforming to Hashable protocol?How to conform custom class with optional properties to “hashable” protocolWhat is the use of hashable protocol in swift4?

My boss says "This will help us better view the utilization of your services." Does this mean my job is ending in this organisation?

Can my UK debt be collected because I have to return to US?

Can there be plants on the dark side of a tidally locked world?

One hour 10 min layover in Newark; International -> Domestic connection. Enough time to clear customs?

How to check status of Wi-Fi adapter through command line?

co-son-in-law or co-brother

Are there photos of the Apollo LM showing disturbed lunar soil resulting from descent engine exhaust?

Do we know the problems the University of Manchester's Transistor Computer was intended to solve?

Can a Beholder face its Antimagic Cone behind itself?

Why is k-means used for non normally distributed data?

stackrel, vertical alignment and math operators

IEEE Registration Authority mac prefix

Lumix G7: Raw photos only in 1920x1440, no higher res available

In mathematics is there a substitution that is "different" from Vieta's substitution to solve the cubic equation?

Taking the first element in a list of associations

Is mathematics truth?

Importance of electrolytic capacitor size

Is there anything in the universe that cannot be compressed?

Remove ads in Viber for PC

What percentage of the mass/energy of the universe is in the form of electromagnetic waves?

Ideal characterization of almost convergence

What is the converted mana cost of land cards?

How to find better food in airports

Disney Musicians Ordering



The Hashable now want to use protocol instead of hashValue but I can't figure it out


NSObject is Hashable but a protocol that adopts NSObject is not?CFString doesn't conform to protocol Hashable?Why can't I call hash() on an apparently hashable method of an unhashable instance?How to handle hash collisions for Dictionaries in SwiftCreating a protocol that represents hashable objects that can be on or offperformance considerations of hashValue in swift protocol HashableHashable protocol for a protocolConforming to Hashable protocol?How to conform custom class with optional properties to “hashable” protocolWhat is the use of hashable protocol in swift4?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I use to have the following code that worked in Swift 4.2 but is now deprecated in Swift 5:



struct xxx: Hashable {
var hashValue: Int return uniqueIdentifier


When I try to use the new hash(into hasher: inout Hasher) I'm not sure what to do. My uniqueIdentifier starts at 0 and keeps incrementing so it's always unique, no need for anything fancy. But it seams to me that I'm now required to have the following code:



func hash(into hasher: inout Hasher) 
hasher.combine(uniqueIdentifier)



Is this true? I don't see why I need to combined my uniqueIdentifier with some seed. Is there a way I can overcome this or I'm I stuck using hasher.combine(uniqueIdentifier)?










share|improve this question






























    2















    I use to have the following code that worked in Swift 4.2 but is now deprecated in Swift 5:



    struct xxx: Hashable {
    var hashValue: Int return uniqueIdentifier


    When I try to use the new hash(into hasher: inout Hasher) I'm not sure what to do. My uniqueIdentifier starts at 0 and keeps incrementing so it's always unique, no need for anything fancy. But it seams to me that I'm now required to have the following code:



    func hash(into hasher: inout Hasher) 
    hasher.combine(uniqueIdentifier)



    Is this true? I don't see why I need to combined my uniqueIdentifier with some seed. Is there a way I can overcome this or I'm I stuck using hasher.combine(uniqueIdentifier)?










    share|improve this question


























      2












      2








      2


      1






      I use to have the following code that worked in Swift 4.2 but is now deprecated in Swift 5:



      struct xxx: Hashable {
      var hashValue: Int return uniqueIdentifier


      When I try to use the new hash(into hasher: inout Hasher) I'm not sure what to do. My uniqueIdentifier starts at 0 and keeps incrementing so it's always unique, no need for anything fancy. But it seams to me that I'm now required to have the following code:



      func hash(into hasher: inout Hasher) 
      hasher.combine(uniqueIdentifier)



      Is this true? I don't see why I need to combined my uniqueIdentifier with some seed. Is there a way I can overcome this or I'm I stuck using hasher.combine(uniqueIdentifier)?










      share|improve this question














      I use to have the following code that worked in Swift 4.2 but is now deprecated in Swift 5:



      struct xxx: Hashable {
      var hashValue: Int return uniqueIdentifier


      When I try to use the new hash(into hasher: inout Hasher) I'm not sure what to do. My uniqueIdentifier starts at 0 and keeps incrementing so it's always unique, no need for anything fancy. But it seams to me that I'm now required to have the following code:



      func hash(into hasher: inout Hasher) 
      hasher.combine(uniqueIdentifier)



      Is this true? I don't see why I need to combined my uniqueIdentifier with some seed. Is there a way I can overcome this or I'm I stuck using hasher.combine(uniqueIdentifier)?







      swift4.2 hashable swift5






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 2:16









      mretondomretondo

      1087 bronze badges




      1087 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389219%2fthe-hashable-now-want-to-use-protocol-instead-of-hashvalue-but-i-cant-figure-it%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389219%2fthe-hashable-now-want-to-use-protocol-instead-of-hashvalue-but-i-cant-figure-it%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript