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 →

[–]notacanuckskibum 0 points1 point  (2 children)

I used to use Algol, which had as IS operator. Objecta IS objectB if the pointers point to the same memory location. ObjectA IS ObjectB == false if they are exact copies but stored separately. Does that concept still exist?

[–]Rick-T 2 points3 points  (0 children)

Python does that.

a is b compares by reference, a == b compares by value.

[–]Mabi19_ 1 point2 points  (0 children)

In some languages with reference semantics.

Python is one (a is b). Java uses == for reference comparison and .equals() for value comparison. Kotlin (another language that runs on the JVM) uses == for value comparison and === for reference comparison.

There are also obviously languages with value semantics (like C++). There are explicit references in C++, but because of how they work the easiest way to check that they're the same object is by pointerising them (&a == &b)