equality Questions

5

Solved

I'm fighting with a custom comparison functions for Lodash's _.isEqualWith. I'd like a function such that this is works: const comparisonFunc = /* ...TBC... */ // Should be true: _.isEqualWith({ ...
Dymoke asked 10/9, 2019 at 16:27

6

Solved

In my test case, I assume that if two values are NaN then they are equal. What is the way to express it using unittest assertions? The two common functions presented below are not handling this cas...
Hitandrun asked 7/8, 2018 at 13:49

1

In (an idealized version of) Haskell, is there a concrete type a such that we can implement Eq a lawfully, but it is impossible to implement Ord a? The order doesn't need to be meaningful, and any ...
Shiva asked 12/5, 2024 at 11:15

7

Solved

I'm trying to use the new (ES6) Map objects in order to represent a map between properties and a value. I have objects in a form similar to: {key1:value1_1,key2:value2_1},..... {key1:value1_N,ke...
Ewall asked 17/2, 2014 at 20:13

10

Solved

I came across this recently, up until now I have been happily overriding the equality operator (==) and/or Equals method in order to see if two references types actually contained the same data (i....
Leroy asked 19/9, 2008 at 18:7

6

Solved

Curiously: >>> a = 123 >>> b = 123 >>> a is b True >>> a = 123. >>> b = 123. >>> a is b False Seems a is b being more or less defined as id(...
Melamine asked 4/7, 2011 at 10:41

17

Solved

I have a class MyClass, which contains two member variables foo and bar: class MyClass: def __init__(self, foo, bar): self.foo = foo self.bar = bar I have two instances of this class, each of w...
Schnell asked 4/8, 2009 at 12:9

3

Solved

My app has two modes: A "run" mode executes very fast without any SwiftUI View update, and a "single step" mode where the user advances the app state manually and needs View upd...
Pallbearer asked 13/9, 2023 at 9:22

2

Solved

From what I understand, records are actually classes that implement their own equality check in a way that your object is value-driven and not reference driven. In short, for the record Foo that is...
Lychnis asked 12/10, 2020 at 23:15

16

Solved

I'm comparing two lists in Dart like this: main() { if ([1,2,3] == [1,2,3]) { print("Equal"); } else { print("Not equal"); } } But they are never equal. There doesn't se...
Holmium asked 1/5, 2012 at 21:19

27

Solved

I wanted to clarify if I understand this correctly: == is a reference comparison, i.e. both objects point to the same memory location .equals() evaluates to the comparison of values in the object...
Tiptop asked 22/9, 2011 at 19:36

4

Solved

The shortest way I can think of to test whether all the elements in an array arr are equal is all(arr[1] .== arr). While this is certainly short, it seems a bit inelegant. Is there a built-in funct...
Broucek asked 30/11, 2017 at 2:13

5

Solved

I have the following code... if (Price_Foreign != Double.NaN) { output.Append(spacer); output.Append(String.Format("{0,-10:C} USD",Price_Foreign)); } Which outputs: NaN USD What gives? I'...
Gannie asked 17/2, 2009 at 19:1

2

System.Collections.IStructuralEquatable and System.Collections.IStructuralComparable were added in .NET 4, but why aren't they generic, like IEquatable<T> and IComparable<T>?
Enzymology asked 11/2, 2011 at 11:41

2

Solved

Why is there a difference between Equal and DeepEqual? s1 := "abc" s2 := "abc" sv1 := reflect.ValueOf(s1) sv2 := reflect.ValueOf(s2) fmt.Println(sv1.Equal(sv2)) fmt.Prin...
Sarilda asked 19/10, 2023 at 11:1

13

Solved

Question (From Eloquent Javascript 2nd Edition, Chapter 4, Exercise 4): Write a function, deepEqual, that takes two values and returns true only if they are the same value or are objects with t...
Spiros asked 22/8, 2014 at 21:49

7

Solved

Is code that uses the static Object.Equals to check for null more robust than code that uses the == operator or regular Object.Equals? Aren't the latter two vulnerable to being overridden in such a...
Hydrocarbon asked 17/8, 2010 at 22:11

12

Solved

I need to compare two numeric values for equality in Javascript. The values may be NaN as well. I've come up with this code: if (val1 == val2 || isNaN(val1) && isNaN(val2)) ... which is ...
Homologate asked 22/1, 2012 at 22:40

6

Solved

Is there a way to get the equality operators to work for comparing arrays of the same type? For example: int x[4] = {1,2,3,4}; int y[4] = {1,2,3,4}; int z[4] = {1,2,3,5}; if (x == y) cout <&lt...
Shan asked 1/9, 2011 at 16:26

12

Solved

Can someone please explain to me why the output from the following code is saying that the arrays are not equal? int main() { int iar1[] = {1, 2, 3, 4, 5}; int iar2[] = {1, 2, 3, 4, 5}; if (ia...
Ferguson asked 12/10, 2012 at 20:12

13

Solved

This question is close, but still not what I want. I'd like to assert in a generic way that two bean objects are equivalent. In case they are not, I'd like a detailed error message explaining the d...
Anybody asked 16/11, 2009 at 9:27

5

Solved

Given two lists of different types, is it possible to make those types convertible between or comparable to each other (eg with a TypeConverter or similar) so that a LINQ query can compare them? I'...
Farleigh asked 3/4, 2012 at 17:43

2

package main import ( "errors" "fmt" ) type myError struct{ err error } func (e myError) Error() string { return e.err.Error() } func new(msg string, args ...any) error { ...
Aubergine asked 19/5, 2022 at 15:40

5

Solved

I need to find out if two dates the user selects are the same in Javascript. The dates are passed to this function in a String ("xx/xx/xxxx").That is all the granularity I need. Here is my code: ...
Hydrogenous asked 3/1, 2011 at 18:16

7

Solved

In the context of unit testing some functions, I'm trying to establish the equality of 2 DataFrames using python pandas: ipdb> expect 1 2 2012-01-01 00:00:00+00:00 NaN 3 2013-05-14 12:00:00+00...
Baribaric asked 11/10, 2013 at 16:3

© 2022 - 2025 — McMap. All rights reserved.