equatable Questions

13

Solved

I need a way of comparing two CLLocationCoordinate2D's however when I tried using == it wouldn't work. Please can someone help me out with the best way of comparing them?
Entopic asked 17/4, 2012 at 21:4

6

Solved

I have an enum of associated values which I would like to make equatable for testing purposes, but do not know how this pattern would work with an enum case with more than one argument. For exampl...
Wehner asked 12/7, 2018 at 7:52

1

I'm trying to implement checkbox logic in bloc class. For that I create List<bool> checked in bloc class code is below. When CheckBoxClicked event trigger then for the first time state update...
Dallman asked 18/8, 2020 at 6:53

10

I don't think this can be done but I'll ask anyway. I have a protocol: protocol X {} And a class: class Y:X {} In the rest of my code I refer to everything using the protocol X. In that code I wo...
Deutoplasm asked 9/2, 2017 at 6:55

3

Solved

For my iOS app I have a model something like class Person { var Id: Int var Name: String init(id: Int, name: String?) { self.Id = id self.Name = name ?? "" } } Then later on in my ViewCon...
Tambratamburlaine asked 6/9, 2015 at 16:42

2

Solved

I have an object that extends Equatable and contains optional parameters. If I try to add that parameter into the props getter, I get an error The element type 'String?' can't be assigned to the li...
Vega asked 14/8, 2021 at 21:0

1

Solved

I've been doing some tests on my models to make sure they are equal when I encode them into JSON and then decode them back using JSONEncoder/Decoder. However, one of my tests failed, and the culpri...
Izard asked 25/6, 2021 at 21:52

3

Solved

Why do we need to use the Equatable class with flutter_bloc? Also, what do we use the props for? Below is sample code for making a state using the bloc pattern in Flutter. abstract class LoginStat...
Charcoal asked 12/10, 2020 at 11:11

2

Value of protocol type 'Any' cannot conform to 'Equatable'; only struct/enum/class types can conform to protocols Value is type "ANY" as it can be Int or String. So not able to implemen...
Timisoara asked 2/5, 2020 at 16:43

2

Solved

I'm quite new to Flutter and Dart, and I have some troubles understanding how to rewrite a class extending an updated version of Equatable. This works with Equatable 0.4.0: abstract class Failure e...
Creaky asked 16/1, 2020 at 14:51

2

Solved

hi I am new with bloc in flutter and I'm trying to understand block timer In the doc of flutter_bloc and I would know what's this constructor class mean @immutable abstract class TimerState exte...
Can asked 27/9, 2019 at 17:3

3

Solved

In order to solve this question, I have been playing around with a custom struct that implements the Hashable Protocol. I'm trying to see how many times the equivalency operator overload (==) gets ...
Almallah asked 28/7, 2015 at 1:3

3

Solved

I have a struct in Swift that looks like this: internal struct MapKey { internal let id: String internal let values: [String:String] } extension MapKey: Equatable {} func ==(lhs: MapKey, rhs: Ma...
Horsy asked 23/6, 2016 at 20:6

4

Solved

I'm trying to implement the == operator (from Equatable) in a base class and its subclasses in Swift 3. All of the classes will only be used in Swift so I do not want to involve NSObject or the NSC...
Broyles asked 7/10, 2016 at 5:8

5

Solved

I've seen the answer to this Swift Equatable Protocol question that mentions how the == method must be declared in the global scope. If I don't adopt Equatable, I still could declare == to test fo...
Favianus asked 6/2, 2016 at 20:19

4

Solved

How do I make a structure conform to protocol "Equatable"? I'm using Xcode 7.3.1 struct MyStruct { var id: Int var value: String init(id: Int, value: String) { self.id = id self.value = val...
Flashover asked 31/5, 2016 at 9:12

2

Solved

I wrote the following extension to remove duplicates from my Array. extension Array where Element : Equatable{ func removeDups() -> [Element]{ var result = [Element]() for element in self...
Privilege asked 10/5, 2018 at 14:48

3

Solved

We have a simple class Person which inherent from realms Object. Now we want that subclass to conform to the Equatable protocol. The very simple code looks like this. class Person: Object, Equat...
Monecious asked 10/5, 2016 at 6:48

2

Solved

I am Having an error in Equatable while compilation. I wanted to add find or contains method in the list to check the value. My Code Below class Generic: NSObject, Equatable, NSCoding //Am Having ...
Maletta asked 23/5, 2016 at 11:47

2

Solved

I have a very simple class in a Playground in Swift 4.0 that overrides the == operator. I'm not understanding why the Swift complier doesn't behave the same when the class inherits/doesn't inherit...

1

The following code compiles in Swift 3 extension Array where Element: Equatable { var removeDuplicate: [Element] { return reduce([]){ $0.0.contains($0.1) ? $0.0 : $0.0 + [$0.1] } } } but prod...
Commutual asked 26/9, 2017 at 16:56

1

Solved

Let's say I'm implementing a root class in Swift, which I declare adopts the Equatable protocol (I want to be able to tell if an array of my type contains a given instance or not). What is the dif...
Mestee asked 20/9, 2016 at 6:21

2

Solved

My goal is to show a user list of history logins ( such as username ) if there are any. In order to do that, I am doing 1. Create an custom object named User like below class User: NSObject { ...
Condensation asked 14/7, 2016 at 20:59

1

Solved

Contains method not working properly and it is giving me false result even if it is matching with Object? My Code Below class Generic: NSObject, NSCoding { var genericCode: String? var generic...
Photomural asked 23/5, 2016 at 12:54

2

Solved

The FooBar class below has to override the == function of the Equatable type. However, calling contains on an array of FooBar objects does not cause a breakpoint inside the custom == functio...
Fond asked 7/5, 2016 at 7:34

© 2022 - 2024 — McMap. All rights reserved.