Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 9071164

Browse files
committed
Added 'equality vs identity' description
Signed-off-by: Serhii Horodilov <sgorodil@gmail.com>
1 parent 8cdae9a commit 9071164

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/basics/bool_logic.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,22 @@ Each of these comparison operators return a Boolean value, it's always
249249

250250
You can chain comparison operators together: ``x < y < z`` is equal to
251251
``x < y and y < z``.
252+
253+
Equality vs Identity
254+
--------------------
255+
256+
It's easier to understand the difference between those by asking the question
257+
each answers to.
258+
259+
The question for ``==`` (*equality*) is:
260+
261+
Is object on the left **equal** to the object on the right
262+
263+
The question for ``is`` (*identity*) is:
264+
265+
Is object on the left **the same** as the object on the right
266+
267+
For example, if there are two cars of the same model, same color etc. in front
268+
of you - these cars are equal, but they aren't ident to each other. But if you
269+
are shown two pictures of the same car, you understand that the cars on those
270+
pictures are the same object.

0 commit comments

Comments
 (0)