ruby - How do I compare objects pointing to a different place in memory? -
i have array of objects:
array = [ obj1, obj2, obj3 ] if query obj1 objects table:
obj1 = objects.get(1) both obj1 , obj1 same objects, when compare them false:
array[0].eql? obj1 # false what's best way compare 2 objects when not pointing @ same place in memory?
actually, these kinds of comparisons of value possessed these same types of objects, need define own comparison operator <=> or whatever sign like, don't override default operators ==. may lead problem.
Comments
Post a Comment