What is the difference between equality and equivalence?

后端 未结 9 776
难免孤独
难免孤独 2020-12-13 07:08

I\'ve read a few instances in reading mathematics and computer science that use the equivalence symbol , (basically an \'=\' with three lines)

9条回答
  •  余生分开走
    2020-12-13 07:29

    A lot of languages distinguish between equality of the objects and equality of the values of those objects.

    Ruby for example has 3 different ways to test equality. The first, equal?, compares two variables to see if they point to the same instance. This is equivalent in a C-style language of doing a check to see if 2 pointers refer to the same address. The second method, ==, tests value equality. So 3 == 3.0 would be true in this case. The third, eql?, compares both value and class type.

    Lisp also has different concepts of equality depending on what you're trying to test.

提交回复
热议问题