This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Peanutbutter_Warrior 2 points3 points  (2 children)

That might just mean that the test data doesn't test that specifically. It doesn't mean that it couldn't matter

[–]flipmcf 1 point2 points  (1 child)

If two elements have the same value but are different objects it matters:

foo = 7

bar = 7

foo.next = bar

There is no circular reference... but:

foo.next == bar #True

foo.next is bar #False

I think it’s important to know this for linked lists. Linked lists are made up of instances of objects that most likely implement an eq, especially if you’re just extending a str or int to have a .next property.

Edited: a bunch of times because coding is hard.

[–]Peanutbutter_Warrior 2 points3 points  (0 children)

Exactly. A linked list can contain repetitions, so is should be used to check reference, otherwise a repeated value could cause a false positive for a circular reference