Thursday, 15 August 2013

ruby - comparing objects pointing to a different place in the memory

ruby - comparing objects pointing to a different place in the memory

I have an array of objects stored some where as below:
array = [ Obj1, Obj2, Obj3 ]
Now I query Obj1 from Objects table:
obj1 = Objects.get(1)
Now both Obj1 and obj are the same objects, but when I compare them I get
false
array[0].eql? obj1 # false
Whats the best way to compare two objects when they are not pointing at
the same place in the memory?

No comments:

Post a Comment