Questions tagged [equivalence]

Equivalence is a relationship in which two or more identifiers are abstractions for the same data structure.

References

168 questions
535
votes
12 answers

Elegant ways to support equivalence ("equality") in Python classes

When writing custom classes it is often important to allow equivalence by means of the == and != operators. In Python, this is made possible by implementing the __eq__ and __ne__ special methods, respectively. The easiest way I've found to do this…
gotgenes
  • 38,661
  • 28
  • 100
  • 128
441
votes
25 answers

How to show loading spinner in jQuery?

In Prototype I can show a "loading..." image with this code: var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); function showLoad () { ... } In jQuery, I can load a server…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
148
votes
4 answers

Why does `if None.__eq__("a")` seem to evaluate to True (but not quite)?

If you execute the following statement in Python 3.7, it will (from my testing) print b: if None.__eq__("a"): print("b") However, None.__eq__("a") evaluates to NotImplemented. Naturally, "a".__eq__("a") evaluates to True, and "b".__eq__("a")…
The AI Architect
  • 1,887
  • 2
  • 17
  • 24
128
votes
7 answers

How to test the equivalence of maps in Golang?

I have a table-driven test case like this one: func CountWords(s string) map[string]int func TestCountWords(t *testing.T) { var tests = []struct { input string want map[string]int }{ {"foo", map[string]int{"foo":1}}, {"foo bar…
andras
  • 6,339
  • 6
  • 26
  • 22
108
votes
7 answers

What is the difference between eq?, eqv?, equal?, and = in Scheme?

I wonder what the difference is between those operations in Scheme. I have seen similar questions in Stack Overflow but they are about Lisp, and there is not a comparison between three of those operators. I am writing the different types of commands…
yrazlik
  • 10,411
  • 33
  • 99
  • 165
42
votes
3 answers

JavaScript equality transitivity is weird

I've been reading Douglas Crockford's JavaScript: The Good Parts, and I came across this weird example that doesn't make sense to me: '' == '0' // false 0 == '' // true 0 == '0' // true false == undefined //…
Hristo
  • 45,559
  • 65
  • 163
  • 230
37
votes
3 answers

Is JavaScript's double equals (==) always symmetric?

There are many cases in which JavaScript's type-coercing equality operator is not transitive. For example, see "JavaScript equality transitivity is weird." However, are there any cases in which == isn't symmetric? That is, where a == b is true and b…
Trevor Burnham
  • 76,828
  • 33
  • 160
  • 196
31
votes
6 answers

Equivalence Class Testing vs. Boundary Value Testing

I understand how equivalence testing works. How is it the same or different from boundary value testing?
neuromancer
  • 53,769
  • 78
  • 166
  • 223
29
votes
8 answers

What is the difference between "conflict serializable" and "conflict equivalent"?

In database theory, what is the difference between "conflict serializable" and "conflict equivalent"? My textbook has a section on conflict serializable but glosses over conflict equivalence. These are probably both concepts I am familiar with, but…
taz
  • 1,506
  • 3
  • 15
  • 26
22
votes
2 answers

Dictionary Keys.Contains vs. ContainsKey: are they functionally equivalent?

I am curious to know if these two are functionally equivalent in all cases. Is it possible that by changing the dictionary's default comparator that these two would be functionally different? Also, isn't Keys.Contains almost guaranteed to be slower?
user420667
  • 6,552
  • 15
  • 51
  • 83
22
votes
4 answers

JavaScript comparison operators: Identity vs. Equality

I've been trying to understand the difference between JavaScript's comparison operators: identity and equality. From what I've read, if you check the equality of two objects using ==, JavaScript will try to figure out if they are the same type and,…
Hristo
  • 45,559
  • 65
  • 163
  • 230
22
votes
1 answer

What is the difference between equivalence and equality?

What is the difference between equivalence and equality in C++? There is a very similar question here. However, this question is tagged with math, while I am interested in the meaning in C++ context. To see the terms in context: Scott Meyers uses…
463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
18
votes
2 answers

Overloading equivalence (==) operator for custom class in Swift

Is it possible to overload equivalence (==) operator for a custom class inside that custom class. However I know that it is possible to have this operator overloaded outside class scope. Appreciate any sample code. Thanks in advance.
Souandios
  • 534
  • 1
  • 4
  • 12
17
votes
4 answers

Boxed Primitives and Equivalence

So I was asked this question today. Integer a = 3; Integer b = 2; Integer c = 5; Integer d = a + b; System.out.println(c == d); What will this program print out? It returns true. I answered it will always print out false because of how I…
John Vint
  • 39,695
  • 7
  • 78
  • 108
16
votes
8 answers

Are there equivalences between Microsoft and Oracle/Sun technologies?

is it possible to say what are the Microsoft equivalents technologies compared to Sun? For example: Microsoft | Oracle/Sun --------------------------------------------------------------- Visual Studio |…
Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
1
2 3
11 12