Questions tagged [equatable]

The Swift equatable protocol can be used to have objects use the equality operators for comparison.

144 questions
1
vote
2 answers

Compare enums in Swift

I have a class that contains two enums like so (made simple): class Errors { enum UserError: String { case NoToken = "No token!" case NoPassword = "No password!" } enum BackendError: String { case NoConnection =…
schnabler
  • 687
  • 7
  • 23
1
vote
1 answer

Implement Equatable for custom private class - Swift

I know how to implement Equatable for a non-private class (by writing the == operator function), however this doesn't work for a private class given that "Operators are only allowed at global scope". Problem is, at global scope, private class is not…
trek
  • 15
  • 3
1
vote
0 answers

swift resolving variable in generic type constrained array parameter

Given class MyClass { static let Anything = 1 func wasCalled(values: [T]) { } } why does this compile: MyClass().wasCalled([1, "a string"]) but this produces "cannot invoke 'wasCalled' with an argument list…
jwilkey
  • 326
  • 3
  • 11
1
vote
3 answers

Setting up equatable for PFObject

I m getting error when setting up equatable in swift extension PFObject : Equatable {} public func ==(lhs:PFObject,rhs:PFObject) -> Bool { return lhs.objectId == rhs.objectId } Below the following error I m getting Redundant conformance of…
Vimlan.G
  • 193
  • 1
  • 13
0
votes
1 answer

Usage of Equatable in Flutter Dart

Im currently working on a Flutter school project. Im totaly new to Flutter and Dart and have troubles to understand the usage of Equatable package. I build my Flutter Application using the Bloc-Pattern. In an online course they described the usage…
Joker
  • 11
  • 1
0
votes
0 answers

No Equatable out of the box in swift for a struct

I've declared my struct to conform to Equatable struct LocationInfo: Equatable { // MARK: - Properties let gatewayId: GatewayId? let gatewaySerialNumber: String? let locationId: LocationId let locationName: String let role:…
Anton Tropashko
  • 5,486
  • 5
  • 41
  • 66
0
votes
1 answer

Protocol constraint Equatable in Swift with ReactiveSwift map function

I am using ReactiveSwift. There are two protocols: CommonProtocol and SpecificProtocol. When I use SpecificProtocol in map function there is an error Type 'any SpecificProtocol' cannot conform to 'Equatable'. However it is perfectly fine with using…
Riddik
  • 2,565
  • 1
  • 11
  • 21
0
votes
0 answers

How do you get automatic Equable conformance for an enum with a closure in Swift?

I have an enum that has several cases with associated values and it conforms to Equatable. I now need to add another case that uses a closure for its associated value and was wandering how I could make it conform to Equatable without having to write…
Edward
  • 2,864
  • 2
  • 29
  • 39
0
votes
1 answer

flutter equatable Too many positional arguments: 0 expected, but 1 found

i was following reso coder's video to learn clean structure and tried to make a super constructor as he did and got this Too many positional arguments: 0 expected, but 1 found. here it is import 'package:equatable/equatable.dart'; import…
Mad Life
  • 1
  • 2
0
votes
0 answers

Class A is not equal to class B with Equatable

here is my model class for a response from the server @JsonSerializable(createToJson: false) @immutable class Miner extends Equatable { final String minerId; @JsonKey(name: 'name') final String minerName; @JsonKey(fromJson: _isOwnerToJson) …
0
votes
3 answers

FLUTTER -BLOC is not updating state even with copyWith() and equatable

I have created an event for radio button like functionality where user can select only single element at a time. But when I trigger the event to select the value, it does not update the state, however the list does get updated. This is my bloc…
Srasti Verma
  • 109
  • 1
  • 8
0
votes
1 answer

Custom Equatable implementation prevents SwiftUI from updating its view

My model Keyword has the following implementation: public struct Keyword: Codable, Equatable, Identifiable { public var id: String { name } public var name: String public var popularity: Int? public static func…
Niels Mouthaan
  • 1,010
  • 8
  • 19
0
votes
0 answers

flutter Equatable with GetxController

I found an excellent way to make a filter using both Equatable and Block But I want to convert it to Get. I tried a lot for days, but I couldn't..Can I get help converting it to Get, please ? The filter method consists of three classes, the first …
Khalid
  • 123
  • 1
  • 7
0
votes
1 answer

Xcode on change not triggering

I have a custom preferences class and I would like to trigger a function whenever that is changed, at the moment it doesn't seem to work for some reason. Here is the class class Preferences: ObservableObject, Equatable{ static func == (lhs:…
Cian B
  • 31
  • 6
0
votes
3 answers

Flutter Equatable Real Life Usage?

I have learned that what is the Equatable and how can I use it. But I just wonder that why should I use it? I have found some reasons. One of them, when we wants to compare 2 or more same object from any class, it will use. they aren't same even if…