2019 | OriginalPaper | Chapter
11. Handling Equality
Published in:
Learn Kotlin for Android Development
Abstract
There is a strong distinction between identity and equality. Two things are identical if they actually are the same. If you bought a white candle this morning, let’s call it A, the white candle in your shopping bag and the white candle that this afternoon is placed in your candleholder are the same and thus identical (presume this is the only candle you own). Now assume you bought a second candle, B, of the same type from the same manufacturer. Apart from some linguistic fluffiness you sometimes hear, those two candles are not the same. Candles A and B are not the same, but they are equal. This is because they have the same characteristics: the same color, the same weight, the same diameter, and the same length. Hold on, though: This is not necessarily true. The manufacturer says such a candle weights 300 g, but a high-precision balance tells us candle A weighs 300.00245 g, and candle B weighs 299.99734 g. If you take a kitchen scale, though, the weights of candles A and B are the same. Therefore you can see that equality depends on strictness and it is relative.