Questions tagged [object-equality]

15 questions
10
votes
1 answer

In Python (2.7), why is os.remove not identical to os.unlink?

>>> import sys >>> sys.version '2.7.3 (default, Mar 13 2014, 11:03:55) \n[GCC 4.7.2]' >>> import os >>> os.remove is os.unlink False >>> os.remove == os.unlink True Why is that? Isn't os.unlink supposed to be an alias of os.remove?
Kal
  • 1,707
  • 15
  • 29
8
votes
2 answers

Char.Equals vs Object.Equals -- ReSharper suggests that I should use Object.Equals. Should I?

Basically, I'm wondering if I should listen to ReSharper in this instance... You'd figure that comparing to characters one should use Char.Equals(char) since it avoids unboxing, but Resharper suggests using Object.Equals(obj). Maybe I'm missing…
myermian
  • 31,823
  • 24
  • 123
  • 215
7
votes
1 answer

Core Data: setPrimitiveValue:forKey: behaves really weirdly

This is a mystery: I'm invoking setPrimitiveValue:forKey: on an NSManagedObject. The key is a legit, persistent, modeled attribute of the object. However, setPrimitiveValue:forKey: fails, often setting the value for a different, arbitrary attribute.…
Steveo
  • 2,238
  • 1
  • 21
  • 34
6
votes
3 answers

JSON object != JavaScript object?

For convenience I wrote a simple toJSON prototype, for handling JSON that I know to be safe: String.prototype.toJSON = function () { return JSON.parse(this.valueOf()); }; I am using it in testing my web-services. Unfortunately even with this…
A T
  • 13,008
  • 21
  • 97
  • 158
4
votes
2 answers

Difference between Object.Equals(objA, objB), objA.Equals(objB) and objA == objB for CLR types?

I am wondering if the CLR types would return different results from the following: Object.Equals(objA, objB) objA.Equals(objB) (objA == objB) I do realize that outside of the CLR someone could easily implement the IEqualtable Equals and overload…
michael
  • 14,844
  • 28
  • 89
  • 177
4
votes
2 answers

Please explain the technique used in this code to test Object Equality and Identity

Please explain the technique used in this code to test Object Equality and Identity. Better, if you can supply me any web-link/book-reference for detailed discussion. [Serializable] public abstract class BusinessObject : IBusinessObject where…
user366312
  • 16,949
  • 65
  • 235
  • 452
4
votes
2 answers

Object equallity in python collections.Counter

I have and instance of collections.Counter class, also i have some objects like: p1 = Person(name='John') p2 = Person(name='John') p3 = Person(name='Jane') I want to hold the counts for this person objects in a instance of Counter, taking into…
angvillar
  • 1,074
  • 3
  • 10
  • 25
3
votes
2 answers

NullReferenceException at Object.Equals(Object, Object)

Situation I'm generating wrappers by using the ILGenerator. I use Object.Equals(Object, Object) For the implementation of the equality compare of the wrapper fields. The debugger throws a NullReferenceException with the following stack trace. at…
Felix K.
  • 6,201
  • 2
  • 38
  • 71
3
votes
1 answer

Best practices for Entity Framework entities override Equals and GetHashCode

I want to check equality between two entities with one-to-many relationships inside them. So obviously I overrode the Object.Equals method, but then I get the CS0659 compiler warning: 'class' overrides Object.Equals(object o) but does not override…
baruchiro
  • 5,088
  • 5
  • 44
  • 66
2
votes
1 answer

What are the requirements for an IdClass in EclipseLink?

The EclipseLink user guide states that when constructing an IdClass (not embedded) for a composite primary key, it must have a public no-argument constructor and implement the methods equals and hashCode. In addition, the example it gives also…
oulenz
  • 1,199
  • 1
  • 15
  • 24
0
votes
1 answer

Python unittest when to test for value or object equality

I have the following code that I'm testing. main.py import helpers def do_something(some_arg): ... return helpers.help_do_something(some_arg) test_main.py import unittest from unittest import mock class…
aydow
  • 3,673
  • 2
  • 23
  • 40
0
votes
0 answers

Jasmine-compatible TypeScript object equality library

Disclaimer: TypeScript (and more generally JavaScript) object equality functions have been discussed en-masse here (e.g., https://stackoverflow.com/a/63496057) and everywhere else (e.g., https://bobbyhadz.com/blog/typescript-object-comparison). I am…
MyKey_
  • 837
  • 1
  • 7
  • 22
0
votes
3 answers

JS use indexOf on an array of objects

I want to use indexOf() on an array of objects. For example: var arr; var arr[0] = {a: 1, b: 2}; var arr[1] = {a: 1, b: 3}; var obj = {a: 1, b: 2}; console.log(arr.indexOf(obj)); This will print -1 because arr[0] does not equal obj. How can I make…
0
votes
1 answer

JComboBox.setSelectedItem() issues

My jTable Column 8 is the U.S. State column. This is my code to set the jComboBox with the appropriate item to display the state. When I used Buffered Reader to fill the Jtable the below code worked really well to set the combobox item. Because of…
-1
votes
1 answer

The same object is not always the same?

Why b is not equal to null at the end of the following code? var a = { property: "value" }, b = a; console.log(a === b); // true a = null; console.log(b); // Object { property: "value" } I thought that a and b are two references tied to one…
Parzh from Ukraine
  • 7,999
  • 3
  • 34
  • 65