Questions tagged [hashable]

This Hashable package defines a class, Hashable, for types that can be converted to a hash value. This class exists for the benefit of hashing-based data structures. The package provides instances for basic types and a way to combine hash values.

161 questions
1
vote
1 answer

How to parse this PayPal JSON response with AnyHashable value using SwiftyJSON?

I'm using PaypalSDK to add paypal payment methods to the app I'm developing, it's already working and when the payment is succesful I'm getting a response which I'm converting into a jsonObject but I don't know how to parse it in order to extract…
Octavio Rojas
  • 187
  • 13
1
vote
0 answers

How to make Array Hashable?

I'm trying to make Array conform to Hashable, in Swift 3 preview 6: extension Array: Hashable where Element: Hashable { public var hashValue: Int { var hashValue = 0 for element in self { hashValue ^=…
Emil Laine
  • 41,598
  • 9
  • 101
  • 157
1
vote
1 answer

Swift: how to make my custom struct Node conform to Hashable?

Node is a generic type. struct Node: Hashable { var label: T init(_ label: T) { self.label = label } var hashValue : Int { get { return label.hashValue } } } extension Node :…
Huang C.
  • 398
  • 6
  • 17
1
vote
1 answer

How to solve TypeError: unhashable type 'list'

I have two lists I would like to modify a particular content of the first list and send the output but when I try to modify it, am getting an error TypeError: unhashable type: 'list'. I am using python with mongodb. The two lists are data = [{"id"…
Tony Roczz
  • 2,366
  • 6
  • 32
  • 59
1
vote
1 answer

CFString doesn't conform to protocol Hashable?

I recently updated to Xcode 6.1 to be able to work with iOS 8.1, but now my latest project in facing an error. I get the error saying that "CFString! does not conform to protocol Hashable", for the following line: let attributes =…
1
vote
0 answers

How can I associate a large number of phrases into clusters/categories?

I'm trying to have a directory site that is still organized by categories and subcategories. Let's say there are a total of 150 subcategories. I would like to have a mySQL db of phrases/keywords (let's say I have 50,000 phrases total, ranging from…
0
votes
0 answers

Why is an array of a Hashable protocol not hashable in Swift 5

I have the following protocol defined that needs to be hashable. But when i create a struct implementing this protocol, the compiler complains: Type 'Example' does not conform to protocol 'Equatable'. public protocol Thing: Hashable { var id:…
Torsten B
  • 413
  • 2
  • 11
0
votes
0 answers

Why Picker requires 'Hashable', when the model is already 'Identifiable' ? Why this requirement comes not up on ScrollView?

When moving the following 'ForEach' code into a Picker, the compiler complaints with: "Generic struct 'Picker' requires that 'Currency' conform to 'Hashable'": // THIS WORKS PERFECTLY ScrollView { …
LukeSideWalker
  • 7,399
  • 2
  • 37
  • 45
0
votes
0 answers

How to make the class 'Sound' conform to 'Hashable' in a ForEach loop in SwiftUI

I am trying to create an audio mixing panel for about 8 audio loops, but the approach I took requires the class Sound to conform to 'Hashable'. I have looked at others who fixed something similar and tried it by simply adding :Hashable, but then it…
Florian
  • 107
  • 1
  • 8
0
votes
2 answers

How to add a tuple which consisting of a list and a string itself into a set in python?

I want to insert multiple tuples into a set which each tuple contains a list and a string. Each tuple looks like: sample_tuple = (['list of elements'], 'one_string') If we check the type of sample_tuple, we can be sure that it is a tuple with 2…
Sara
  • 419
  • 1
  • 6
  • 14
0
votes
2 answers

Get dict keys using pandas apply

i want to get values from the dict that looks like pair_devices_count = {('tWAAAA.jg', 'ttNggB.jg'): 1, ('tWAAAM.jg', 'ttWVsM.jg'): 2, ('tWAAAN.CV', 'ttNggB.AS'): 1, ('tWAAAN.CV', 'ttNggB.CV'): 2, ('tWAAAN.CV', 'ttNggB.QG'): 1} (Pairs of…
0
votes
0 answers

Fatal error: Duplicate keys of type 'ArraySlice' were found in a Dictionary. But I am not using any Dictionaries

I have a tree data structure where each node has an id, type and children: final class Node: Equatable, Hashable { var id: String = UUID().uuidString var type: String = "" var children: [Node] = [] func hash(into hasher: inout Hasher) { …
0
votes
2 answers

Looping an AnyHashable Dictionary

I am trying to loop the information that I got from a Http response, but I am having trouble accessing the data. this is currently the information I am trying to Loop: I was trying to use a For to access the different elements of the response but…
Ricardo Guerrero
  • 433
  • 1
  • 5
  • 21
0
votes
1 answer

SwiftUI - using ForEach with a Binding array that does not conform to identifiable / hashable

I have the a codable object as follows: struct IncidentResponse: Codable { let incident: IncidentDetails? } struct IncidentDetails: Codable, Identifiable { let id: String? let reason: IncidentReasonResponse? let message: String? …
DevB1
  • 1,235
  • 3
  • 17
  • 43
0
votes
1 answer

How is memory handled in Python's Lists?

See the code below, as you see when a=[1,2] that is a homogeneous type the address of 1st and 2nd elements differed by 32 bits but in second case when a=[1,'a',3],there is no relation between address of 1st and 2nd element but there is relation…
Darshan V
  • 198
  • 9