All Questions

727
votes
23answers
2839383 views

How do I compare strings in Java?

I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug. Is == bad? When should it ...
5251
votes
49answers
1294635 views

Which equals operator (== vs ===) should be used in JavaScript comparisons?

I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value.le...
407
votes
19answers
214960 views

How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

What is the difference between == and ===? How exactly does the loosely == comparison work? How exactly does the strict === comparison work? What would be some useful examples?
142
votes
21answers
123836 views

What's wrong with using == to compare floats in Java?

According to this java.sun page == is the equality comparison operator for floating point numbers in Java. However, when I type this code: if(sectionID == currentSectionID) into my editor and run ...
162
votes
8answers
123504 views

equals vs Arrays.equals in Java

When comparing arrays in Java, are there any differences between the following 2 statements? array1.equals(array2); Arrays.equals(array1, array2); And if so what are they?
412
votes
4answers
774118 views

String comparison in Python: is vs. ==

I noticed a Python script I was writing was acting squirrelly, and traced it to an infinite loop, where the loop condition was while line is not ''. Running through it in the debugger, it turned out t...
165
votes
4answers
157635 views

Is False == 0 and True == 1 in Python an implementation detail or is it guaranteed by the language?

Is it guaranteed that False == 0 and True == 1, in Python? For instance, is it in any way guaranteed that the following code will always produce the same results, whatever the version of Python (both...
117
votes
5answers
118580 views

jQuery object equality

How do I determine if two jQuery objects are equal? I would like to be able to search an array for a particular jQuery object. $.inArray(jqobj, my_array);//-1 alert($("#deviceTypeRoot") == $("#de...
88
votes
0answers
50927 views

php == vs === operator

What is the difference between == and === in php. I am unsure when to use both. Updated note: So that it shows up in StackOverflow search, the difference between == and === is the same as the differe...
258
votes
17answers
83220 views

Best practices for overriding isEqual: and hash

How do you properly override isEqual: in Objective-C? The "catch" seems to be that if two objects are equal (as determined by the isEqual: method), they must have the same hash value. The Introspect...

Previous Next