redd icon indicating copy to clipboard operation
redd copied to clipboard

Implement Equality (==) on Models

Open christopher-dG opened this issue 8 years ago • 1 comments
trafficstars

Last thing I'll bug you with for a while!

I have a comment child, and that comment is the only reply to another comment parent.

reply = parent.reload.replies[0]
reply.body == child.body  # => true
reply.id == child.id  # => true
reply == child  # => false

I don't think that you can uniquely identify a comment with just its ID, but if you can get the post ID that they each replied to, then you could compare reply.id == child.id && reply.subreddit.id == child.subreddit.id && post_id == child.post_id (this already works for link posts with link_id but I'm not sure if an equivalent exists for self posts.

christopher-dG avatar Apr 05 '17 15:04 christopher-dG

Actually, you can indeed just compare ids. Comments have unique ids, so as long as you're not comparing Submission IDs with Comment IDs, id should be fine. Leaving this one open as well, can't believe I haven't implemented this!

avinashbot avatar Apr 05 '17 18:04 avinashbot